fix: support dual-namespace definitions (function + module same name)#5
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_poolreplaces same-type entries (last-writer-wins per type) and appends new types, preserving source order within each slotpack()flattens the list-of-lists when assemblingused_defscompute_reachablepasses the full list tocollect_called_namesso both the module body and function body are traversed for reachabilityAdd 7 new tests covering the dual-namespace behaviour (
TestDualNamespacein test_packer.py,test_dual_namespace_traverses_all_defsin test_shaker.py). All 112 tests pass with 100% branch coverage.