Commit 26055dc
authored
Fix BoundsError with mixed file provenance not caused by macros (JuliaLang/JuliaLowering.jl#75)
Was causing several stdlib failures. MWE:
```
julia> ex = Meta.parse("begin
x = 111
x = 222
end")
JuliaLowering.core_lowering_hook(ex, Main, "foo.jl", 100)
```
If `core_lowering_hook` is given one filename (e.g. "none" from `@eval`), but
some part of the expression contains LineNumberNodes with a different
filename, we trigger the "inlined macro-expansion" logic in the debuginfo
generator, which assumes new filenames are from new macro expansions atop
the old filename. The violated invariant is that the list of files in this
statement's flattened provenance shares some prefix with the last
statement's list of files.
This fix assumes there is some base file that all statements share, and
normalizes different base filenames to the first it sees.
Aside: Not sure if this stack logic is 100% correct given that two adjacent
statements can share arbitrarily many file stack entries despite being from
different macro expansions.1 parent 395b2a1 commit 26055dc
2 files changed
+17
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
86 | 93 | | |
87 | 94 | | |
88 | 95 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 96 | | |
93 | 97 | | |
94 | 98 | | |
95 | 99 | | |
| 100 | + | |
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
0 commit comments