Fix `none:-1` stack frame from generator/comprehension expressions (#61939)
Fix #33457. Nightly:
```
julia> begin
# line 2
[y for _ in 1:10]
# line 4
end
ERROR: UndefVarError: `y` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] #2
@ ./none:-1 [inlined]
[2] iterate
@ ./generator.jl:48 [inlined]
[3] collect(itr::Base.Generator{UnitRange{Int64}, var"#2#3"})
@ Base ./array.jl:833
[4] top-level scope
@ REPL[1]:3
```
This change:
```
ERROR: UndefVarError: `y` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] #12
@ ./REPL[1]:3 [inlined]
[2] iterate
@ ./generator.jl:48 [inlined]
[3] collect(itr::Base.Generator{UnitRange{Int64}, var"#12#13"})
@ Base ./array.jl:833
[4] top-level scope
@ REPL[1]:3
```
As a sneak peek, this is further improved with #61699:
```
ERROR: UndefVarError: `y` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
[1] (::var"#12#13")(::Int64)
@ Main REPL[1]:3 [inlined]
[2] iterate(::Base.Generator{UnitRange{Int64}, var"#12#13"})
@ Base generator.jl:48 [inlined]
[3] collect(itr::Base.Generator{UnitRange{Int64}, var"#12#13"})
@ Base array.jl:833
[4] top-level scope
@ REPL[1]:3
```
I doubt this frame is important (it being a lambda is considered an
implementation detail IIRC) but (1) we shouldn't show users a nonsense
frame,
and (2) this fixes another case where we produce malformed DebugInfo. E
Em Chu committed
3a5a39a934ecbcb4c9b61caffdee848d1f67ccf1
Parent: 0d22f19
Committed by GitHub <noreply@github.com>
on 5/29/2026, 9:22:38 AM