base64.lua: correct daw_register self-registration guard (truthy check) #44

Closed
opened 2026-08-10 17:49:16 +02:00 by michael · 1 comment
Owner

Goal

Correct base64.lua's self-registration guard from
type(_G.daw_register) == "function" to the accepted simple truthy
check if _G.daw_register then _G.daw_register(_NAME, M) end, matching
every other production file in this repository.

Why

Found during the DAW/daw-lua-net 2.1.0 team review session, while
verifying a reviewer claim that daw-lua-net should revert its
daw_register guard back to the type-check pattern. Cross-checking
against the actual daw-lua-common source showed:

grep -rc "if _G.daw_register then" --include='*.lua' . | grep -v :0 | wc -l
# 20 files (24 counting facade-style files like json/encode.lua with
#  multiple guards)

grep -rc "type(_G.daw_register)" --include='*.lua' . | grep -v :0
# ./base64.lua:1

24 of 25 production files already use the truthy check. base64.lua is
the sole outlier -- a leftover from before the pattern was adopted
project-wide. This matches the accepted decision recorded in the
session findings (truthy check is the lived/correct pattern) and
DAW/daw-docs#18 (which corrects the standard document, not the code
-- the code in daw-lua-common is already right everywhere except here).

Scope

  • base64.lua: change the registration guard from
    if type(_G.daw_register) == "function" then
      _G.daw_register(_NAME, M)
    end
    
    to
    if _G.daw_register then _G.daw_register(_NAME, M) end
    
  • No other behavior change.

Acceptance criteria

  • base64.lua uses the truthy _G.daw_register guard, matching
    the other 24 production files in this repo.
  • No other code in base64.lua changed.
  • make test passes on Lua 5.1 and 5.4.
  • fragjan code . clean.

Cross-repository context

Related to DAW/daw-docs#18 (documentation correction for the same
pattern) and the daw-lua-net 2.1.0 migration session
(DAW/daw-lua-net#8, DAW/daw-lua-net#9), where this discrepancy
surfaced during team review.

## Goal Correct `base64.lua`'s self-registration guard from `type(_G.daw_register) == "function"` to the accepted simple truthy check `if _G.daw_register then _G.daw_register(_NAME, M) end`, matching every other production file in this repository. ## Why Found during the DAW/daw-lua-net 2.1.0 team review session, while verifying a reviewer claim that daw-lua-net should revert its `daw_register` guard back to the type-check pattern. Cross-checking against the actual daw-lua-common source showed: ```sh grep -rc "if _G.daw_register then" --include='*.lua' . | grep -v :0 | wc -l # 20 files (24 counting facade-style files like json/encode.lua with # multiple guards) grep -rc "type(_G.daw_register)" --include='*.lua' . | grep -v :0 # ./base64.lua:1 ``` 24 of 25 production files already use the truthy check. `base64.lua` is the sole outlier -- a leftover from before the pattern was adopted project-wide. This matches the accepted decision recorded in the session findings (truthy check is the lived/correct pattern) and DAW/daw-docs#18 (which corrects the *standard document*, not the code -- the code in daw-lua-common is already right everywhere except here). ## Scope - `base64.lua`: change the registration guard from ```lua if type(_G.daw_register) == "function" then _G.daw_register(_NAME, M) end ``` to ```lua if _G.daw_register then _G.daw_register(_NAME, M) end ``` - No other behavior change. ## Acceptance criteria - [ ] `base64.lua` uses the truthy `_G.daw_register` guard, matching the other 24 production files in this repo. - [ ] No other code in `base64.lua` changed. - [ ] `make test` passes on Lua 5.1 and 5.4. - [ ] `fragjan code .` clean. ## Cross-repository context Related to DAW/daw-docs#18 (documentation correction for the same pattern) and the daw-lua-net 2.1.0 migration session (DAW/daw-lua-net#8, DAW/daw-lua-net#9), where this discrepancy surfaced during team review.
Author
Owner

Done

base64.lua now uses the accepted truthy guard
('if _G.daw_register then ... end'). The change went in with
f7d9df9 (feat(i18n): add daw_i18n/v1 resources for base64 and
config_parser). Verified on main: no 'type(_G.daw_register)' guard
remains in any production Lua file.

## Done base64.lua now uses the accepted truthy guard ('if _G.daw_register then ... end'). The change went in with f7d9df9 (feat(i18n): add daw_i18n/v1 resources for base64 and config_parser). Verified on main: no 'type(_G.daw_register)' guard remains in any production Lua file.
michael 2026-09-20 21:36:46 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/daw-lua-common#44
No description provided.