Skip to content

Add buildScopesInto for a scope table shared across files - #8

Merged
revarbat merged 1 commit into
mainfrom
shared-scope-table-across-use
Sep 6, 2026
Merged

revarbat merged 1 commit into
mainfrom
shared-scope-table-across-use

Conversation

@revarbat

@revarbat revarbat commented Sep 6, 2026

Copy link
Copy Markdown
Member

Follow-up to #7, fixing a regression it introduced.

A resolution can span several files: use <file> gives each used file its own root Scope, and a used file may itself use another. One evaluation reads all of them back, so every node's scope has to land in ONE table.

buildScopes() creates a table and attaches it to the root it returns — right for a single tree, wrong for that case. Each level built its own table and only the outermost survived, so the evaluation saw no scope at all for a used file's nodes and use silently resolved to undef:

echo(combo());   // ECHO: 107  ->  ECHO: undef

Fix

buildScopesInto() records into a table the caller owns and does not attach it, so a multi-file resolution can thread one through and hand it to the outermost root at the end. buildScopes() is now that plus the allocation.

Verified

  • 648 parser tests
  • Downstream: 1154 evaluator tests (incl. a new nested-use case that fails without this), 31 binding tests, BelfrySCAD's 1296, BOSL2's 909

🤖 Generated with Claude Code

A resolution can span several files: `use <file>` gives each used file its
own root Scope, and a used file may itself `use` another. One evaluation
reads all of them back, so every node's scope has to land in ONE table.

buildScopes() creates a table and attaches it to the root it returns, which
is right for a single tree and wrong for that case -- each level built its
own table and only the outermost survived, so the evaluation saw no scope at
all for a used file's nodes and `use` silently resolved to undef.

buildScopesInto() records into a table the caller owns and does not attach
it, so a multi-file resolution can thread one through and hand it to the
outermost root at the end. buildScopes() is now that plus the allocation.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@revarbat
revarbat merged commit a62a7ea into main Sep 6, 2026
3 checks passed
@revarbat
revarbat deleted the shared-scope-table-across-use branch September 6, 2026 17:45
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