JuliaLang / JuliaSyntax.jl

The Julia compiler frontend
Other
267 stars 32 forks source link

Potential regression in JuliaSyntax parser failure error message #375

Closed KristofferC closed 7 months ago

KristofferC commented 8 months ago

On 1.10:

julia> "\≈"
┌ Error: JuliaSyntax parser failed — falling back to flisp!
│   exception =
│    StringIndexError: invalid index [4], valid nearby indices [3]=>'≈', [6]=>'\"'
│    Stacktrace:
│      [1] string_index_err(s::String, i::Int64)
│        @ Base ./strings/string.jl:12
│      [2] SubString{String}(s::String, i::Int64, j::Int64)
│        @ Base ./strings/substring.jl:34
│      [3] SubString
│        @ Base ./strings/substring.jl:41 [inlined]
│      [4] SubString
│        @ Base ./strings/substring.jl:47 [inlined]
│      [5] SubString
│        @ Base ./strings/substring.jl:43 [inlined]
│      [6] getindex
│        @ Base ./strings/substring.jl:292 [inlined]
│      [7] getindex(source::Base.JuliaSyntax.SourceFile, rng::UnitRange{Int64})
│        @ Base.JuliaSyntax /cache/build/default-amdci5-7/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/source_files.jl:109
│      [8] highlight(io::IOBuffer, source::Base.JuliaSyntax.SourceFile, range::UnitRange{Int64}; color::Tuple{Int64, Int64, Int64}, context_lines_before::Int64, context_lines_inner::Int64, context_lines_after::Int64, note::String, notecolor::Symbol)
│        @ Base.JuliaSyntax /cache/build/default-amdci5-7/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/source_files.jl:221
│      [9] highlight
│        @ Base.JuliaSyntax /cache/build/default-amdci5-7/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/source_files.jl:190 [inlined]
│     [10] show_diagnostic(io::IOBuffer, diagnostic::Base.JuliaSyntax.Diagnostic, source::Base.JuliaSyntax.SourceFile)

On 1.11

julia> "\≈"
┌ Error: JuliaSyntax parser failed — falling back to flisp!
│   exception = (StringIndexError("\"\\≈\"", 4), Union{Ptr{Nothing}, Base.InterpreterIP}[Ptr{Nothing} @0x00007f2f3be66422, Ptr{Nothing} @0x00007f2f3bd155e2, Ptr{Nothing} @0x00007f2f3ba8694a, Ptr{Nothing} @0x00007f2f3bca685a, Ptr{Nothing} @0x00007f2f3be991af, Ptr{Nothing} @0x00007f2f3be99573, Ptr{Nothing} @0x00007f2f3bfd04ca, Ptr{Nothing} @0x00007f2f3c03bb6b, Ptr{Nothing} @0x00007f2f3bac5928, Ptr{Nothing} @0x00007f2f3be9bcec, Ptr{Nothing} @0x00007f2f63a550fd, Ptr{Nothing} @0x00007f2f63a575ad, Ptr{Nothing} @0x00007f2f3bf8b4f3, Ptr{Nothing} @0x00007f2f63a575ad, Ptr{Nothing} @0x00007f2f3c01e5fa, Ptr{Nothing} @0x00007f2f63a575ad, Ptr{Nothing} @0x00007f2f3ba7f2fd, Ptr{Nothing} @0x00007f2f63a575ad, Ptr{Nothing} @0x00007f2f3bcf7011, Ptr{Nothing} @0x00007f2f3c088513, Ptr{Nothing} @0x00007f2edd31f38c, Ptr{Nothing} @0x00007f2edd42eb72, Ptr{Nothing} @0x00007f2f63a54f5d, Ptr{Nothing} @0x00007f2edd31efdb, Ptr{Nothing} @0x00007f2edd37f5d0, Ptr{Nothing} @0x00007f2f63a54f5d, Ptr{Nothing} @0x00007f2edd35182e, Ptr{Nothing} @0x00007f2edd2c275e, Ptr{Nothing} @0x00007f2edd31f76e, Ptr{Nothing} @0x00007f2edd3da41d, Ptr{Nothing} @0x00007f2edd37fa36, Ptr{Nothing} @0x00007f2f63a6aa94])
│   offset = 0
│   code = "\≈"
└ @ Base.JuliaSyntax /home/kc/julia/base/JuliaSyntax/src/hooks.jl:258
ERROR: syntax: invalid escape sequence
c42f commented 8 months ago

This is really weird - I think this is something to do with recent Logging (or other) changes in Base because we haven't changed anything about how we emit this error here in JuliaSyntax itself.

[Separately, do we track this particular failure of string indexing anywhere? That's a separate bug which needs fixing]

KristofferC commented 7 months ago

Probably https://github.com/JuliaLang/julia/issues/52075

c42f commented 7 months ago

Yes that will definitely be the root cause of the error printing going haywire :+1:

I just fixed the issue you noticed to trigger the error log (#387) so I think we can close this :)