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

REPL becomes unusable after error #37783

Closed
barucden opened this issue Sep 28, 2020 · 2 comments · Fixed by #49368
Closed

REPL becomes unusable after error #37783

barucden opened this issue Sep 28, 2020 · 2 comments · Fixed by #49368
Labels
bug Indicates an unexpected problem or unintended behavior duplicate Indicates similar issues or pull requests

Comments

@barucden
Copy link
Contributor

I stumbled upon a (not very critical, just inconvenient) error when using the REPL. Using the following I always get the displayed error.

julia> l = [1 => 2]
1-element Array{Pair{Int64,Int64},1}:
 1 => 2

julia> (x=>y) = l[1]
Error showing value of type UnionAll:
ERROR: 
SYSTEM (REPL): showing an error caused an error
ERROR: 
SYSTEM (REPL): caught exception of type MethodError while trying to handle a nested exception; giving up

After that, the REPL session cannot be used anymore because subsequent calls result in the following.

julia> 1+1
┌ Error: Error in the keymap
│   exception =
│    MethodError: no method matching isspace(::Int64)
│    Closest candidates are:
│      isspace(::AbstractChar) at strings/unicode.jl:466
│    Stacktrace:
│     [1] rstrip(::typeof(isspace), ::String) at ./strings/util.jl:259
│     [2] rstrip(::String) at ./strings/util.jl:263
│     [3] add_history(::REPL.REPLHistoryProvider, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:570
│     [4] add_history(::REPL.LineEdit.PromptState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:1229
│     [5] add_history(::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:208
│     [6] commit_line(::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:1995
│     [7] (::REPL.LineEdit.var"#110#163")(::Any, ::Any, ::Vararg{Any,N} where N) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2077
│     [8] #invokelatest#1 at ./essentials.jl:710 [inlined]
│     [9] invokelatest at ./essentials.jl:709 [inlined]
│     [10] (::REPL.LineEdit.var"#22#23"{REPL.LineEdit.var"#110#163",String})(::Any, ::Any) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:1364
│     [11] prompt!(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2447
│     [12] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2350
│     [13] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:1143
│     [14] (::REPL.var"#38#42"{REPL.LineEditREPL,REPL.REPLBackendRef})() at ./task.jl:356
└ @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/REPL/src/LineEdit.jl:2449

My Julia version:

Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-9.0.1 (ORCJIT, haswell)

On the current nighly build (1.6.0-DEV.1065), the result is the same, but the last error is slightly different:

julia> 1+1
┌ Error: Error in the keymap
│   exception =
│    TypeError: in typeassert, expected AbstractChar, got a value of type Int64
│    Stacktrace:
│      [1] rstrip(f::typeof(isspace), s::String)
│        @ Base ./strings/util.jl:259
│      [2] rstrip
│        @ ./strings/util.jl:263 [inlined]
│      [3] add_history(hist::REPL.REPLHistoryProvider, s::REPL.LineEdit.PromptState)
│        @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:547
│      [4] add_history(s::REPL.LineEdit.PromptState)
│        @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:1248
│      [5] add_history(::REPL.LineEdit.MIState)
│        @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:227
│      [6] commit_line(s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2075
│      [7] (::REPL.LineEdit.var"#110#163")(::REPL.LineEdit.MIState, ::Any, ::Vararg{Any, N} where N)
│        @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2157
│      [8] #invokelatest#2
│        @ ./essentials.jl:709 [inlined]
│      [9] invokelatest
│        @ ./essentials.jl:708 [inlined]
│     [10] (::REPL.LineEdit.var"#22#23"{REPL.LineEdit.var"#110#163", String})(s::Any, p::Any)
│        @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:1414
│     [11] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2528
│     [12] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│        @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2430
│     [13] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│        @ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:1124
│     [14] (::REPL.var"#44#49"{REPL.LineEditREPL, REPL.REPLBackendRef})()
│        @ REPL ./task.jl:392
└ @ REPL.LineEdit /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:253
@KristofferC KristofferC added the bug Indicates an unexpected problem or unintended behavior label Sep 28, 2020
@KristofferC
Copy link
Member

KristofferC commented Sep 28, 2020

What happens is that you replace the Pair constructor with nonsense and then the whole of julia comes crashing down (because it uses Pairs internally).

A more MWE would be:

julia> =>
Pair

julia> Pair(a,b) = error()
Error showing value of type UnionAll:
ERROR:
SYSTEM (REPL): showing an error caused an error
ERROR:
SYSTEM (REPL): caught exception of type ErrorException while trying to handle a nested exception; giving up

And since Pair is not a method but a constructor, you don't have to import it like with e.g.

julia> +
+ (generic function with 184 methods)

julia> +(a,b) = error()
ERROR: error in method definition: function Base.+ must be explicitly imported to be extended

I think this could be fixed by making =>(a,b) = Pair(a,b) instead of const => = Pair like it is now?

@KristofferC
Copy link
Member

And would you look at that... Closing as dup of #25744

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior duplicate Indicates similar issues or pull requests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants