fix: berhtjan-core init.lua -- unprotected require, global _NAME #7

Closed
opened 2026-05-25 20:34:08 +02:00 by michael · 4 comments
Owner

Problems

  1. All five require calls are unprotected -- no pcall.
    A missing submodule produces a raw Lua stack trace.

    Affected: loader, composer, types, scanner, lang

  2. _NAME is declared without local -- pollutes global namespace.
    All other daw modules use local _NAME.

Fix

  • Add local to _NAME declaration
  • Wrap each require in pcall with [ERROR] message and exit 10

See also

## Problems 1. All five require calls are unprotected -- no pcall. A missing submodule produces a raw Lua stack trace. Affected: loader, composer, types, scanner, lang 2. `_NAME` is declared without `local` -- pollutes global namespace. All other daw modules use `local _NAME`. ## Fix - Add `local` to _NAME declaration - Wrap each require in pcall with [ERROR] message and exit 10 ## See also - DAW/fragjan#37 (same pattern in fragjan main.lua) - DAW/fragjan#40 (rule: unprotected require)
Author
Owner

Also: require("daw.common.json") in loader.lua is unprotected -- same fix needed there.

Also: require("daw.common.json") in loader.lua is unprotected -- same fix needed there.
Author
Owner

Also unprotected require in composer.lua: require("daw.berhtjan_core.types"). Same fix needed there.

Also unprotected require in composer.lua: require("daw.berhtjan_core.types"). Same fix needed there.
Author
Owner

scanner.lua: three points:

  1. require("daw.common.fs") unprotected at module level.
  2. require("daw.berhtjan_core.loader") inside load_contributions unprotected.
  3. Dead code in scan_root recursive branch: 'if names' check after 'if not names then return' is always true -- remove.
scanner.lua: three points: 1. require("daw.common.fs") unprotected at module level. 2. require("daw.berhtjan_core.loader") inside load_contributions unprotected. 3. Dead code in scan_root recursive branch: 'if names' check after 'if not names then return' is always true -- remove.
Author
Owner

Fixed:

  • init.lua: _NAME declared local
  • scanner.lua: dead code removed (unreachable if names check after nil guard)
  • All require calls wrapped in pcall with _check_deps pattern (loader, composer, types, scanner, lang)
  • loader.lua, composer.lua: pcall+_check_deps for module-level requires
  • scanner.lua: pcall for inline loader require in load_contributions()
    All tests passing on Lua 5.1 and 5.4.
Fixed: - init.lua: _NAME declared local - scanner.lua: dead code removed (unreachable if names check after nil guard) - All require calls wrapped in pcall with _check_deps pattern (loader, composer, types, scanner, lang) - loader.lua, composer.lua: pcall+_check_deps for module-level requires - scanner.lua: pcall for inline loader require in load_contributions() All tests passing on Lua 5.1 and 5.4.
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-modul-berhtjan-core#7
No description provided.