Closed topolarity closed 1 year ago
It would be very nice in general not to print the long backtrace here.
Instead, I think it'd be better to provide instructions for reporting this bug upstream.
Maybe we can turn that from @error
to @debug
? With an @error
to "report issue upstream"
I view this type of error similarly to an unexpected internal error in the Julia runtime—we need to avoid them entirely, not make them pretty, though I also think this error message should be more clear that it should be reported upstream.
Just hit a similar case (on 1.10.0-beta2
):
julia> map([3,4,5])[1] do
┌ Error: JuliaSyntax parser failed — falling back to flisp!
│ exception =
│ Internal error: length(args) == 3
│ Stacktrace:
│ [1] error(::String, ::String)
│ @ Base ./error.jl:44
│ [2] internal_error(strs::String)
│ @ Base.JuliaSyntax /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/utils.jl:23
│ [3] _internal_node_to_Expr(source::Base.JuliaSyntax.SourceFile, srcrange::UnitRange{…}, head::Base.JuliaSyntax.SyntaxHead, childranges::Vector{…}, childheads::Vector{…}, args::Vector{…})
│ @ Base.JuliaSyntax /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/expr.jl:399
│ [4] _to_expr(node::Base.JuliaSyntax.SyntaxNode)
│ @ Base.JuliaSyntax /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/expr.jl:496
│ [5] _to_expr(node::Base.JuliaSyntax.SyntaxNode) (repeats 2 times)
│ @ Base.JuliaSyntax /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/expr.jl:495
│ [6] Expr(node::Base.JuliaSyntax.SyntaxNode)
│ @ Base.JuliaSyntax /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/expr.jl:500
│ [7] core_parser_hook(code::String, filename::String, lineno::Int64, offset::Int64, options::Symbol)
│ @ Base.JuliaSyntax /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/hooks.jl:209
│ [8] invoke_in_world(::UInt64, ::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{})
│ @ Base ./essentials.jl:921
│ [9] invoke_in_world(::UInt64, ::Any, ::Any, ::Vararg{Any})
│ @ Base ./essentials.jl:918
│ [10] (::Base.JuliaSyntax.var"#invoke_fixedworld#120"{Base.JuliaSyntax.var"#invoke_fixedworld#117#121"{…}})(::String, ::Vararg{Any}; kws::@Kwargs{})
│ @ Base.JuliaSyntax /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/hooks.jl:118
│ [11] (::Base.JuliaSyntax.var"#invoke_fixedworld#120"{Base.JuliaSyntax.var"#invoke_fixedworld#117#121"{…}})(::String, ::Vararg{Any})
│ @ Base.JuliaSyntax /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/hooks.jl:117
│ [12] _parse_string(text::String, filename::String, lineno::Int64, index::Int64, options::Symbol)
│ @ Base.Meta ./meta.jl:200
│ [13] #parseall#6
│ @ Base.Meta ./meta.jl:294 [inlined]
│ [14] parseall
│ @ Base.Meta ./meta.jl:293 [inlined]
│ [15] _parse_input_line_core
│ @ Base ./client.jl:174 [inlined]
│ [16] #parse_input_line#1007
│ @ Base ./client.jl:192 [inlined]
│ [17] parse_input_line
│ @ Base ./client.jl:189 [inlined]
│ [18] (::REPL.var"#93#103"{REPL.LineEditREPL, REPL.REPLHistoryProvider})(x::Any)
│ @ REPL ~/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1077
│ [19] #invokelatest#2
│ @ Base ./essentials.jl:887 [inlined]
│ [20] invokelatest
│ @ Base ./essentials.jl:884 [inlined]
│ [21] (::REPL.var"#do_respond#80"{Bool, Bool, REPL.var"#93#103"{…}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
│ @ REPL ~/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:903
│ [22] #invokelatest#2
│ @ Base ./essentials.jl:887 [inlined]
│ [23] invokelatest
│ @ Base ./essentials.jl:884 [inlined]
│ [24] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│ @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2656
│ [25] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│ @ REPL ~/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1310
│ [26] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│ @ REPL ~/.julia/juliaup/julia-1.10.0-beta2+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:386
│ offset = 0
│ code = "map([3,4,5])[1] do x"
└ @ Base.JuliaSyntax /cache/build/default-amdci5-3/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/hooks.jl:258
ERROR: syntax: extra token "do" after end of expression
Stacktrace:
[1] top-level scope
@ none:1
Both of these are fixed on 1.11.0-DEV.470 (Commit d51ad06f66* (2023-09-14 20:13 UTC))
and broken on 1.10.0-beta2
. They should be fixed on 1.10.0-beta3
(or -rc1), but leaving this issue open until beta3 comes out and someone confirms.
https://github.com/JuliaLang/julia/pull/50928
https://github.com/JuliaLang/julia/pull/50971
I can confirm these are fixed in rc1
Parsing this malformed code:
triggers this unhelpful error + huge backtrace from JuliaSyntax: