Fix None filtering, scope serialization, and Assignment RHS scoping#3
Merged
Fix None filtering, scope serialization, and Assignment RHS scoping#3
Conversation
3 tasks
…on exclusion, Assignment RHS pre-assignment scope Co-authored-by: revarbat <350001+revarbat@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add lexical scope support to AST nodes
Fix None filtering, scope serialization, and Assignment RHS scoping
Mar 19, 2026
revarbat
reviewed
Mar 19, 2026
revarbat
requested changes
Mar 19, 2026
…tion literals are closures, lazy-evaluated) Co-authored-by: revarbat <350001+revarbat@users.noreply.github.com>
revarbat
approved these changes
Mar 19, 2026
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.
Three correctness issues identified in code review of the lexical scope feature.
Changes
builder.py—visit_module_definitionnow skipsNoneitems when flattening children (viaelif item is not None).visit_statement()can returnNonefor empty nodes; those were propagating intoModuleDeclaration.childrenand crashingbuild_scope().serialization.py—scopeis now excluded from field serialization alongsideposition. Afterbuild_scopes()runs,node.scopeis aScopeinstance that_serialize_value()can't handle, causingTypeErrorinast_to_dict/json/yaml.nodes.py—Assignment.build_scope()now always passesparent_scope(the full scope) to the RHS expression. Function literal bodies are closures that resolve variables lazily at call time, so the full enclosing scope — including the variable being assigned — must be visible. This correctly handles both direct function literal assignments and expressions that contain function literals (e.g. a ternary whose branches are function literals):📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.