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

This demo of v1.10's feature [[], [], [,] [], []] fails with OhMyREPL #335

Closed
vlad-circadia opened this issue Dec 28, 2023 · 15 comments
Closed

Comments

@vlad-circadia
Copy link

julia> [[], [], [,] [], []]
ERROR: ParseError:

Stacktrace:
 [1] top-level scope
   @ none:1
SYSTEM (REPL): showing an error caused an error
ERROR: KeyError: key :light_black not found
Stacktrace:
  [1] getindex
    @ ./dict.jl:498 [inlined]
  [2] _printstyled(io::IOContext{Base.TTY}, text::String; fgcolor::Symbol, bgcolor::Nothing, href::Nothing)
    @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/utils.jl:104
  [3] _printstyled
    @ /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/utils.jl:96 [inlined]
  [4] show_diagnostic(io::IOContext{Base.TTY}, diagnostic::Base.JuliaSyntax.Diagnostic, source::Base.JuliaSyntax.SourceFile)
    @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/diagnostics.jl:89
  [5] show_diagnostics(io::IOContext{Base.TTY}, diagnostics::Vector{Base.JuliaSyntax.Diagnostic}, source::Base.JuliaSyntax.SourceFile)
    @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/diagnostics.jl:102
  [6] showerror(io::IOContext{Base.TTY}, err::Base.JuliaSyntax.ParseError)
    @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/parser_api.jl:26
  [7] showerror(io::IOContext{Base.TTY}, ex::Base.Meta.ParseError)
    @ Base ./errorshow.jl:42
  [8] showerror(io::IOContext{Base.TTY}, ex::Base.Meta.ParseError, bt::Vector{Base.StackTraces.StackFrame}; backtrace::Bool)
    @ Base ./errorshow.jl:95
  [9] show_exception_stack(io::IOContext{Base.TTY}, stack::Base.ExceptionStack)
    @ Base ./errorshow.jl:975
 [10] display_error(io::IOContext{Base.TTY}, stack::Base.ExceptionStack)
    @ Base ./client.jl:111
=== truncated here ===
@vlad-circadia vlad-circadia changed the title This demo of v1.10's feature [[], [], [,] [], []] fails with OhMyREPL This demo of v1.10's feature [[], [], [,] [], []] fails with OhMyREPL Dec 28, 2023
@KristofferC
Copy link
Owner

Oops 😅

@KristofferC
Copy link
Owner

KristofferC commented Dec 28, 2023

Hmm, this seems to be from JuliaSyntax.jl here:

https://github.com/JuliaLang/JuliaSyntax.jl/blob/a6f2d1580f7bbad11822033e8c83e607aa31f100/src/utils.jl#L103-L104

But this checks if haskey(_fg_color_codes, fgcolor) before accessing it so I am not sure how this error happens.

The key should also be defined in https://github.com/JuliaLang/JuliaSyntax.jl/blob/a6f2d1580f7bbad11822033e8c83e607aa31f100/src/utils.jl#L72.

@KristofferC
Copy link
Owner

Also, it seems to work fine for me.

@vlad-circadia
Copy link
Author

Hm, interesting. Check out this two scenarios:

  1. No error
➜  ~ julia --startup-file=no
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> [[], [], [,] [], []]
ERROR: ParseError:
# Error @ REPL[1]:1:11
[[], [], [,] [], []]
#         ╙ ── unexpected `,`
Stacktrace:
 [1] top-level scope
   @ none:1

julia> using OhMyREPL

julia> [[], [], [,] [], []]
ERROR: ParseError:
# Error @ REPL[2]:1:11
[[], [], [,] [], []]
#         ╙ ── unexpected `,`
Stacktrace:
 [1] top-level scope
   @ none:1
  1. Error!
➜  ~ julia --startup-file=no
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using OhMyREPL

julia> [[], [], [,] [], []]
ERROR: ParseError:

Stacktrace:
 [1] top-level scope
   @ none:1
SYSTEM (REPL): showing an error caused an error
ERROR: KeyError: key :light_black not found
Stacktrace:
  [1] getindex
    @ ./dict.jl:498 [inlined]
  [2] _printstyled(io::IOContext{Base.TTY}, text::String; fgcolor::Symbol, bgcolor::Nothing, href::Nothing)
    @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/utils.jl:104
  [3] _printstyled
    @ /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/utils.jl:96 [inlined]
  [4] show_diagnostic(io::IOContext{Base.TTY}, diagnostic::Base.JuliaSyntax.Diagnostic, source::Base.JuliaSyntax.SourceFile)
    @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/diagnostics.jl:89
  [5] show_diagnostics(io::IOContext{Base.TTY}, diagnostics::Vector{Base.JuliaSyntax.Diagnostic}, source::Base.JuliaSyntax.SourceFile)
    @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/diagnostics.jl:102
  [6] showerror(io::IOContext{Base.TTY}, err::Base.JuliaSyntax.ParseError)
    @ Base.JuliaSyntax /Users/julia/.julia/scratchspaces/a66863c6-20e8-4ff4-8a62-49f30b1f605e/agent-cache/default-honeycrisp-HL2F7YQ3XH.0/build/default-honeycrisp-HL2F7YQ3XH-0/julialang/julia-release-1-dot-10/base/JuliaSyntax/src/parser_api.jl:26
  [7] showerror(io::IOContext{Base.TTY}, ex::Base.Meta.ParseError)
    @ Base ./errorshow.jl:42
  [8] showerror(io::IOContext{Base.TTY}, ex::Base.Meta.ParseError, bt::Vector{Base.StackTraces.StackFrame}; backtrace::Bool)
    @ Base ./errorshow.jl:95
  [9] show_exception_stack(io::IOContext{Base.TTY}, stack::Base.ExceptionStack)
    @ Base ./errorshow.jl:975
 [10] display_error(io::IOContext{Base.TTY}, stack::Base.ExceptionStack)
    @ Base ./client.jl:111
 [11] #invokelatest#2
    @ Base ./essentials.jl:887 [inlined]
 [12] invokelatest
    @ Base ./essentials.jl:884 [inlined]
 [13] repl_display_error(errio::IO, errval::Any)
    @ REPL /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/REPL/src/REPL.jl:293
 [14] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/REPL/src/REPL.jl:310
 [15] (::REPL.var"#57#58"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/REPL/src/REPL.jl:284
 [16] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/REPL/src/REPL.jl:569
 [17] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/REPL/src/REPL.jl:282
 [18] (::REPL.var"#do_respond#80"{…})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/REPL/src/REPL.jl:911
 [19] #invokelatest#2
    @ Base ./essentials.jl:887 [inlined]
 [20] invokelatest
    @ Base ./essentials.jl:884 [inlined]
 [21] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2656
 [22] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1312
 [23] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL /Applications/Julia-1.10.app/Contents/Resources/julia/share/julia/stdlib/v1.10/REPL/src/REPL.jl:386
Some type information was truncated. Use `show(err)` to see complete types.

@Moelf
Copy link
Contributor

Moelf commented Dec 29, 2023

akako@frame ~> julia --startup-file=no
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> [[], [], [,] [], []]
ERROR: ParseError:
# Error @ REPL[1]:1:11
[[], [], [,] [], []]
#         ╙ ── unexpected `,`
Stacktrace:
 [1] top-level scope
   @ none:1

julia> using OhMyREPL

julia> [[], [], [,] [], []]
ERROR: ParseError:
# Error @ REPL[2]:1:11
[[], [], [,] [], []]
#         ╙ ── unexpected `,`
Stacktrace:
 [1] top-level scope
   @ none:1

works fine for

  [5fb14364] OhMyREPL v0.5.23

@vlad-circadia
Copy link
Author

Thanks for checking @Moelf! Could you also try the second scenario, where OhMyREPL is loaded first thing in the Julia session? That's where the error occurs on my side.

@Moelf
Copy link
Contributor

Moelf commented Dec 29, 2023

doesn't make any difference on my end:

akako@frame ~> julia --startup-file=no
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using OhMyREPL

julia> [[], [], [,] [], []]
ERROR: ParseError:
# Error @ REPL[2]:1:11
[[], [], [,] [], []]
#         ╙ ── unexpected `,`
Stacktrace:
 [1] top-level scope
   @ none:1

@vlad-circadia
Copy link
Author

Good, thanks. What platform are you at @Moelf?
I've just tried it out on a Linux box. Everything works fine indeed:

LDN-WS-Ubuntu :: ~ » julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using OhMyREPL

julia> [[], [], [,] [], []]
ERROR: ParseError:
# Error @ REPL[2]:1:11
[[], [], [,] [], []]
#         ╙ ── unexpected `,`
Stacktrace:
 [1] top-level scope
   @ none:1

@vlad-circadia
Copy link
Author

A bit more context: the problem is observed on a Mac M2 machine, but not on a Linux (Ubuntu).
The Mac's version info:

julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M2 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
  Threads: 1 on 6 virtual cores

@vlad-circadia
Copy link
Author

This error's root cause is most likely outside of OhMyREPL.
The following error, similar to the one reported here, is observed on a Mac, but not Linux machine:

julia> bar = Dict(:a=>1)
julia> bar[:a]
ERROR: KeyError: key :a not found
Stacktrace:
 [1] getindex(h::Dict{Symbol, Int64}, key::Symbol)
   @ Base ./dict.jl:498
 [2] top-level scope
   @ REPL[31]:1

@vlad-circadia
Copy link
Author

Sorry, in view of JuliaLang/julia#52816 (comment) I have to retract my previous statement. The issue seems to be somehow related to OhMyREPL on a Mac-Mx platform.

@vlad-circadia
Copy link
Author

I still have no clue what kind of gremlin hides here. The issue, however, has a remedy: call Base.getindex() prior to activating OhMyREPL. I.e., put something like this at the top of startup.jl before using OhMyREPL:

let 
    foo = Dict(:a => 1, :b => 2)[:a]
end

I'd still be curious about the root cause, though.

@vlad-circadia
Copy link
Author

vlad-circadia commented Jan 11, 2024

As another attempt at understanding what's going on, I've checked out OhMyREPL for development and removed the explicit dependency on JuliaSyntax since as of Julia v1.10 JuliaSyntax is shipped with the Base.

Comment out import JuliaSyntax in OhMyREPL.jl:

__precompile__()
"""
A package that provides a new REPL that has syntax highlighting,
bracket matching and other nifty features.
"""
module OhMyREPL

# import JuliaSyntax
using Crayons
if VERSION > v"1.3"
import JLFzf
end

import REPL

export colorscheme!, colorschemes, enable_autocomplete_brackets, enable_highlight_markdown, enable_fzf, test_colorscheme

const SUPPORTS_256_COLORS = !(Sys.iswindows() && VERSION < v"1.5.3")
<cut>

It worked! Julia's behaviour became as intended:

➜  julia --startup-file=no
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.10.0 (2023-12-25)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using OhMyREPL

julia> [[,]]
ERROR: ParseError:
# Error @ REPL[2]:1:3
[[,]]
# ╙ ── unexpected `,`
Stacktrace:
 [1] top-level scope
   @ none:1

The experiment shows that there is a mismatch between Base.JuliaSyntax and its standalone version. This confirms that the problem is not with OhMyREPL as such, I believe.

@vlad-circadia
Copy link
Author

vlad-circadia commented Jan 11, 2024

Digging a bit deeper, the Base.JuliaSyntax version is 0.4.7 while OhMyREPL is using the latest v0.4.8.

As one would expect, downgrading JuliaSyntax to v0.4.7 also resolves the issue with OhMyREPL without the need to modify the latter. Although, I still think that it is a good idea for OhMyREPL to drop the dependency on JuliaSyntax for Julia v1.10 and later.

@vlad-circadia
Copy link
Author

Ehmmm... I've revered JuliaSyntax back to v0.4.8 and OhMyREPL back to its official version and... I cannot reproduce the error anymore. Very confusing 😕, but good I guess.

I'm closing the issue as sporadic and apparently specific to my setup. Sorry for the mess @KristofferC

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

No branches or pull requests

3 participants