Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "not your fault" hint to the fallback to flisp error #358

Merged
merged 3 commits into from
Oct 17, 2023

Conversation

LilithHafner
Copy link
Member

Adds "This is probably not your fault, please submit a bug report (https://github.com/JuliaLang/JuliaSyntax.jl/issues)" to the long message when JuliaSytnax has an internal bug.

julia> map([3,4,5])[1] do x
┌ Error: JuliaSyntax parser failed — falling back to flisp!
│ This is probably not your fault, please submit a bug report (https://github.com/JuliaLang/JuliaSyntax.jl/issues)
│   exception =
│    Internal error: length(args) == 3
│    Stacktrace:
│      [1] error(::String, ::String)
│        @ Base ./error.jl:44
│      [2] internal_error(strs::String)
│        @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/utils.jl:23
│      [3] _internal_node_to_Expr(source::Base.JuliaSyntax.SourceFile, srcrange::UnitRange{Int64}, head::Base.JuliaSyntax.SyntaxHead, childranges::Vector{UnitRange{Int64}}, childheads::Vector{Base.JuliaSyntax.SyntaxHead}, args::Vector{Any})
│        @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/expr.jl:399
│      [4] _to_expr(node::Base.JuliaSyntax.SyntaxNode)
│        @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/expr.jl:496
│      [5] _to_expr(node::Base.JuliaSyntax.SyntaxNode) (repeats 2 times)
│        @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/expr.jl:495
│      [6] Expr(node::Base.JuliaSyntax.SyntaxNode)
│        @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/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 ./REPL[6]:72
│      [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"{typeof(Base.JuliaSyntax.core_parser_hook), UInt64}})(::String, ::Vararg{Any}; kws::@Kwargs{})
│        @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/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"{typeof(Base.JuliaSyntax.core_parser_hook), UInt64}})(::String, ::Vararg{Any})
│        @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-R17H3W25T9.0/build/default-honeycrisp-R17H3W25T9-0/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.aarch64.apple.darwin14/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.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
│        @ REPL ~/.julia/juliaup/julia-1.10.0-beta2+0.aarch64.apple.darwin14/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.aarch64.apple.darwin14/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.aarch64.apple.darwin14/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.aarch64.apple.darwin14/share/julia/stdlib/v1.10/REPL/src/REPL.jl:386
│   offset = 0
│   code = "map([3,4,5])[1] do x"
└ @ Base.JuliaSyntax REPL[6]:121
ERROR: syntax: extra token "do" after end of expression
Stacktrace:
 [1] top-level scope
   @ none:1

From @topolarity and @vchuravy 's commentary here #340

@codecov
Copy link

codecov bot commented Sep 15, 2023

Codecov Report

Merging #358 (e621db4) into main (a57f093) will decrease coverage by 0.80%.
Report is 2 commits behind head on main.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
- Coverage   96.56%   95.76%   -0.80%     
==========================================
  Files          14       13       -1     
  Lines        4161     3895     -266     
==========================================
- Hits         4018     3730     -288     
- Misses        143      165      +22     
Files Coverage Δ
src/hooks.jl 80.92% <0.00%> (-2.12%) ⬇️

... and 13 files with indirect coverage changes

Copy link
Member

@c42f c42f left a comment

Choose a reason for hiding this comment

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

Lovely, let's do this! I'd use a triple quoted string rather than * but either way :-)

@PallHaraldsson
Copy link

How about "This is not your fault" (i.e. needing to send a bug report)? JuliaSyntax.jl should parse legal, and all illegal code, so it's never the users fault?! Though if illegal could have gotten an ERROR message from JuliaSyntax.jl, and then in that sense the users fault.

@LilithHafner
Copy link
Member Author

Lovely, let's do this! I'd use a triple quoted string rather than * but either way :-)

Agreed, triple quoted is better.

@PallHaraldsson I don't understand what you're saying. Yes, JuliaSyntax should be able to handle any input string, legal or illegal, but like all nontrivial software, JuliaSyntax has bugs. This PR improves the user experience when folks hit those bugs and encourage them to report the bugs they hit so we can fix them.

@PallHaraldsson
Copy link

Yes it has bugs, and we want them reported, but with "probably" it seems like you're blaming the user for that. It didn't seem necessary. I want an error/clarification, just thought the wording could be adjusted.

src/hooks.jl Outdated Show resolved Hide resolved
Co-authored-by: Sebastian Pfitzner <pfitzseb@gmail.com>
@pfitzseb pfitzseb merged commit b941fc0 into main Oct 17, 2023
31 of 32 checks passed
@pfitzseb pfitzseb deleted the lh/flisp-fallback-hint branch October 17, 2023 14:48
c42f pushed a commit that referenced this pull request Nov 12, 2023
Co-authored-by: Sebastian Pfitzner <pfitzseb@gmail.com>
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.

None yet

4 participants