Skip to content

[JuliaLowering] Add soft_scope kwarg to resolve_scopes#61476

Open
aviatesk wants to merge 1 commit intoavi/JL-fix-soft-scopefrom
avi/JL-soft-scope-override
Open

[JuliaLowering] Add soft_scope kwarg to resolve_scopes#61476
aviatesk wants to merge 1 commit intoavi/JL-fix-soft-scopefrom
avi/JL-soft-scope-override

Conversation

@aviatesk
Copy link
Copy Markdown
Member

@aviatesk aviatesk commented Apr 2, 2026

Add soft_scope::Union{Nothing,Bool}=nothing keyword argument to resolve_scopes so callers can explicitly control soft scope behavior without inserting K"softscope" marker nodes into the AST. When nothing (the default), the existing marker-based detection is used.

This is useful for tools like JETLS that lower code from different contexts (files vs notebooks). Notebook cells use REPL-like soft scope semantics, and with this kwarg, the language server can pass soft_scope=true directly rather than manipulating the AST to insert marker nodes.

Add `soft_scope::Union{Nothing,Bool}=nothing` keyword argument
to `resolve_scopes` so callers can explicitly control soft scope
behavior without inserting `K"softscope"` marker nodes into the
AST. When `nothing` (the default), the existing marker-based
detection is used.

This is useful for tools like JETLS that lower code from
different contexts (files vs notebooks). Notebook cells use
REPL-like soft scope semantics, and with this kwarg, the
language server can pass `soft_scope=true` directly rather
than manipulating the AST to insert marker nodes.
@aviatesk aviatesk requested a review from mlechu April 2, 2026 11:11
aviatesk added a commit to aviatesk/JETLS.jl that referenced this pull request Apr 2, 2026
JuliaLang/julia#61476 allows us to remove the `insert_softscope_marker`
workaround that inserted `K"softscope"` nodes into the AST and pass
the `soft_scope` keword arg directly instead.
aviatesk added a commit to aviatesk/JETLS.jl that referenced this pull request Apr 2, 2026
JuliaLang/julia#61476 allows us to remove the `insert_softscope_marker`
workaround that inserted `K"softscope"` nodes into the AST and pass
the `soft_scope` keword arg directly instead.
aviatesk added a commit to aviatesk/JETLS.jl that referenced this pull request Apr 2, 2026
JuliaLang/julia#61476 allows us to remove the `insert_softscope_marker`
workaround that inserted `K"softscope"` nodes into the AST and pass
the `soft_scope` keword arg directly instead.
Copy link
Copy Markdown
Member

@mlechu mlechu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds OK. I've talked about wanting to make this a parameter instead of using the AST marker. We might want to make it a parameter to lowering (like world) instead of just scope resolution to keep the interface cleaner, though.

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.

2 participants