Skip to content

fix: support dual-namespace definitions (function + module same name)#5

Merged
tbjers merged 1 commit into
mainfrom
fix/dual-namespace-pool-collision
Jun 5, 2026
Merged

fix: support dual-namespace definitions (function + module same name)#5
tbjers merged 1 commit into
mainfrom
fix/dual-namespace-pool-collision

Conversation

@tbjers

@tbjers tbjers commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

OpenSCAD has separate function and module namespaces. BOSL defines several names (assertion, assert_in_list, echo_error, echo_warning, deprecate, deprecate_argument) as both a module and a function.

The previous _pool (dict[str, single_node]) overwrote the first definition when a second definition with the same name was encountered, causing 'WARNING: Ignoring unknown module assertion' from OpenSCAD when packing BOSL-dependent files.

Widen _pool to dict[str, list[...]] so both definitions coexist:

  • _add_to_pool replaces same-type entries (last-writer-wins per type) and appends new types, preserving source order within each slot
  • pack() flattens the list-of-lists when assembling used_defs
  • compute_reachable passes the full list to collect_called_names so both the module body and function body are traversed for reachability

Add 7 new tests covering the dual-namespace behaviour (TestDualNamespace in test_packer.py, test_dual_namespace_traverses_all_defs in test_shaker.py). All 112 tests pass with 100% branch coverage.

OpenSCAD has separate function and module namespaces. BOSL defines
several names (assertion, assert_in_list, echo_error, echo_warning,
deprecate, deprecate_argument) as both a module and a function.

The previous _pool (dict[str, single_node]) overwrote the first
definition when a second definition with the same name was encountered,
causing 'WARNING: Ignoring unknown module assertion' from OpenSCAD when
packing BOSL-dependent files.

Widen _pool to dict[str, list[...]] so both definitions coexist:
- _add_to_pool replaces same-type entries (last-writer-wins per type)
  and appends new types, preserving source order within each slot
- pack() flattens the list-of-lists when assembling used_defs
- compute_reachable passes the full list to collect_called_names so
  both the module body and function body are traversed for reachability

Add 7 new tests covering the dual-namespace behaviour (TestDualNamespace
in test_packer.py, test_dual_namespace_traverses_all_defs in
test_shaker.py). All 112 tests pass with 100% branch coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (db63c16) to head (48d054b).

Additional details and impacted files
@@             Coverage Diff             @@
##             main        #5      +/-   ##
===========================================
+ Coverage   99.29%   100.00%   +0.70%     
===========================================
  Files           6         6              
  Lines         141       146       +5     
  Branches       27        29       +2     
===========================================
+ Hits          140       146       +6     
+ Partials        1         0       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tbjers
tbjers merged commit c28e402 into main Jun 5, 2026
9 checks passed
@tbjers
tbjers deleted the fix/dual-namespace-pool-collision branch June 5, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant