Error when editing macro name
theogf opened this issue · comments
In my startup.jl, I have:
using OhMyREPL
OhMyREPL.enable_autocomplete_brackets(false)
When I added the following macro (in startup.jl) (just a text plain alternative to @show
):
macro println(ex)
:(println($(sprint(Base.show_unquoted, ex)), " = ", repr(MIME("text/plain"), begin local value = $(esc(ex)) end)))
end
when testing it, @println rand(3);
worked, but went to edit println
to replace it with show
(in the repl), I got the following error:
julia> @┌ Error: Error in the keymap
│ exception =
│ InexactError: trunc(UInt32, -1)
│ Stacktrace:
│ [1] throw_inexacterror(f::Symbol, #unused#::Type{UInt32}, val::Int64)
│ @ Core ./boot.jl:634
│ [2] checked_trunc_uint
│ @ ./boot.jl:664 [inlined]
│ [3] toUInt32
│ @ ./boot.jl:748 [inlined]
│ [4] UInt32
│ @ ./boot.jl:788 [inlined]
│ [5] convert
│ @ ./number.jl:7 [inlined]
│ [6] ParseStreamPosition
│ @ ~/.julia/packages/JuliaSyntax/DHdTk/src/parse_stream.jl:168 [inlined]
│ [7] fix_macro_name_kind!(ps::JuliaSyntax.ParseState, macro_name_position::JuliaSyntax.ParseStreamPosition, name_kind::Nothing)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:2344
│ [8] fix_macro_name_kind!
│ @ ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:2336 [inlined]
│ [9] parse_call_chain(ps::JuliaSyntax.ParseState, mark::JuliaSyntax.ParseStreamPosition, is_macrocall::Bool)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:1513
│ [10] parse_atom(ps::JuliaSyntax.ParseState, check_identifiers::Bool)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:3539
│ [11] parse_atom
│ @ ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:3391 [inlined]
│ [12] parse_unary_prefix(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:1449
│ [13] parse_call(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:1410
│ [14] parse_factor(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:1358
│ [15] parse_unary(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:1175
│ [16] parse_juxtapose(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:1122
│ [17] parse_where(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_juxtapose))
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:1080
│ [18] parse_unary_subtype(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:1041
│ [19] parse_LtoR(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_unary_subtype), is_op::typeof(JuliaSyntax.is_prec_bitshift))
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:367
│ [20] parse_shift(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:1008
│ [21] parse_LtoR(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_shift), is_op::typeof(JuliaSyntax.is_prec_rational))
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:367
│ [22] parse_rational(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:1002
│ [23] parse_with_chains(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_rational), is_op::typeof(JuliaSyntax.is_prec_times), chain_ops::Tuple{JuliaSyntax.Kind})
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:956
│ [24] parse_term(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:948
│ [25] parse_with_chains(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_term), is_op::typeof(JuliaSyntax.is_prec_plus), chain_ops::Tuple{JuliaSyntax.Kind, JuliaSyntax.Kind})
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:956
│ [26] parse_expr(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:941
│ [27] parse_invalid_ops(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:926
│ [28] parse_range(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:836
│ [29] parse_LtoR(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_range), is_op::typeof(JuliaSyntax.is_prec_pipe_gt))
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:367
│ [30] parse_pipe_gt(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:823
│ [31] parse_RtoL(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_pipe_gt), is_op::typeof(JuliaSyntax.is_prec_pipe_lt), self::typeof(JuliaSyntax.parse_pipe_lt))
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:382
│ [32] parse_pipe_lt(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:816
│ [33] parse_comparison(ps::JuliaSyntax.ParseState, subtype_comparison::Bool)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:774
│ [34] parse_comparison(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:766
│ [35] parse_lazy_cond(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_comparison), is_op::typeof(JuliaSyntax.is_prec_lazy_and), self::typeof(JuliaSyntax.parse_and))
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:731
│ [36] parse_and(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:759
│ [37] parse_lazy_cond(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_and), is_op::typeof(JuliaSyntax.is_prec_lazy_or), self::typeof(JuliaSyntax.parse_or))
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:731
│ [38] parse_or(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:750
│ [39] parse_arrow(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:707
│ [40] parse_cond(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:645
│ [41] parse_RtoL(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_cond), is_op::typeof(JuliaSyntax.is_prec_pair), self::typeof(JuliaSyntax.parse_pair))
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:382
│ [42] parse_pair(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:636
│ [43] parse_comma(ps::JuliaSyntax.ParseState, do_emit::Bool)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:613
│ [44] parse_comma
│ @ ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:611 [inlined]
│ [45] parse_assignment
│ @ ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:574 [inlined]
│ [46] parse_eq
│ @ ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:551 [inlined]
│ [47] parse_docstring(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_eq))
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:509
│ [48] parse_docstring
│ @ ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:507 [inlined]
│ [49] parse_Nary(ps::JuliaSyntax.ParseState, down::typeof(JuliaSyntax.parse_docstring), delimiters::Tuple{JuliaSyntax.Kind}, closing_tokens::Tuple{JuliaSyntax.Kind})
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:412
│ [50] parse_stmts(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:485
│ [51] parse_toplevel(ps::JuliaSyntax.ParseState)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser.jl:450
│ [52] #parse!#81
│ @ ~/.julia/packages/JuliaSyntax/DHdTk/src/parser_api.jl:46
│ [53] parse!
│ @ ~/.julia/packages/JuliaSyntax/DHdTk/src/parser_api.jl:43 [inlined]
│ [54] tokenize(text::String)
│ @ JuliaSyntax ~/.julia/packages/JuliaSyntax/DHdTk/src/parser_api.jl:181
│ [55] rewrite_with_ANSI(s::Any, cursormove::Bool)
│ @ OhMyREPL.Prompt ~/.julia/packages/OhMyREPL/zRJyJ/src/repl.jl:67
│ [56] rewrite_with_ANSI
│ @ ~/.julia/packages/OhMyREPL/zRJyJ/src/repl.jl:25 [inlined]
│ [57] refresh_line
│ @ ~/.julia/packages/OhMyREPL/zRJyJ/src/refresh_lines.jl:5 [inlined]
│ [58] edit_backspace(s::REPL.LineEdit.PromptState, align::Bool, adjust::Bool)
│ @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.0+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:888
│ [59] edit_backspace
│ @ ~/.julia/juliaup/julia-1.9.0+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:886 [inlined]
│ [60] edit_backspace(s::REPL.LineEdit.MIState, args::Any)
│ @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.0+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:249
│ [61] (::OhMyREPL.BracketInserter.var"#6#13"{Vector{Char}, Vector{Char}})(s::REPL.LineEdit.MIState, data::REPL.LineEditREPL, c::String)
│ @ OhMyREPL.BracketInserter ~/.julia/packages/OhMyREPL/zRJyJ/src/BracketInserter.jl:158
│ [62] #invokelatest#2
│ @ ./essentials.jl:816 [inlined]
│ [63] invokelatest
│ @ ./essentials.jl:813 [inlined]
│ [64] (::REPL.LineEdit.var"#27#28"{OhMyREPL.BracketInserter.var"#6#13"{Vector{Char}, Vector{Char}}, String})(s::Any, p::Any)
│ @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.0+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:1603
│ [65] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│ @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.0+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2740
│ [66] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
│ @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.0+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2642
│ [67] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
│ @ REPL ~/.julia/juliaup/julia-1.9.0+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300
└ @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.0+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2742
From your path OhMyREPL/zRJyJ
I see you're using version 0.5.20 ? Which uses JuliaSyntax-0.3.3 and has a known bug JuliaLang/JuliaSyntax.jl#236 which has since been solved.
So updating your version of OhMyREPL should fix this!
See JuliaLang/JuliaSyntax.jl#236 (comment) for detail