Skip to content

Expose lexical bindings for unexecuted Python functions - #9

Merged
Sam Gammon (sgammon) merged 1 commit into
elide-25.5.xfrom
fix/null-frame-lexical-scopes
Nov 1, 2026
Merged

Sam Gammon (sgammon) merged 1 commit into
elide-25.5.xfrom
fix/null-frame-lexical-scopes

Conversation

@sgammon

Copy link
Copy Markdown
Member

Parsing an uncalled Python function exposed an empty lexical scope through NodeLibrary.getScope(node, null, ...). For example, neither outer nor inner was visible in def inspect(outer): inner = outer; return inner.

Use the Bytecode DSL code unit's parameter/local, cell, and free-variable tables for null-frame scope enumeration. Exclude dot-prefixed compiler bindings such as .0, and report values as unreadable and unwritable without a frame. Live-frame scope/value handling is preserved. Document why node entry versus exit does not change Python function lexical membership.

The regression instrument registers a source-section listener before parsing, which exposes nested uncalled roots without executing the module. It covers all four existing instrumentation-option combinations, closures and captured parameters, global/nonlocal declarations, names before assignment, generators, async functions, class closures, Unicode identifiers, hidden comprehension arguments, source locations, both nodeEnter values, and changed contents at the same URI.

Validation on macOS/AArch64:

  • Confirmed the original function scope was empty before the fix.
  • mx --java-home=lookup:default --suitemodel nested python-jvm passed.
  • mx --java-home=lookup:default --suitemodel nested unittest LexicalScopeTests PythonDebugTest passed: 16 tests.
  • Eclipse formatting, checkstyle, copyright, and whitespace checks passed.

Integration note: a one-shot source-section visit after parsing saw only the module in the initial probe. Register the load listener before parsing, as in the regression instrument. This change does not add a static-analysis service or promise complete module/class namespace metadata. Native Image and Elide's probe against a newly published artifact remain follow-up validation.

Patch tracking: elide-dev/graal#3.

@sgammon
Sam Gammon (sgammon) merged commit 8020c13 into elide-25.5.x Nov 1, 2026
12 of 16 checks passed
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