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

Errors when using Unicode string #39

Open
tomyun opened this issue Jun 19, 2020 · 6 comments
Open

Errors when using Unicode string #39

tomyun opened this issue Jun 19, 2020 · 6 comments

Comments

@tomyun
Copy link
Contributor

tomyun commented Jun 19, 2020

julia> using Reduce
Reduce (Free CSL version, revision 5286), 01-Mar-20 ...
REPL mode REDUCE initialized. Press } to enter and backspace to exit.

reduce> α;
ERROR: StringIndexError("α;", 2)
Stacktrace:
 [1] string_index_err(::String, ::Int64) at ./strings/string.jl:12
 [2] getindex at ./strings/string.jl:250 [inlined]
 [3] parserepl(::String) at /Users/tomyun/.julia/packages/Reduce/fWMAZ/src/repl.jl:32
 [4] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [5] invokelatest at ./essentials.jl:711 [inlined]
 [6] (::REPL.var"#do_respond#38"{Bool,typeof(Reduce.parserepl),REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:724
 [7] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [8] invokelatest at ./essentials.jl:711 [inlined]
 [9] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/LineEdit.jl:2354
 [10] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:1055
 [11] run_repl(::REPL.AbstractREPL, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:206
 [12] (::Base.var"#764#766"{Bool,Bool,Bool,Bool})(::Module) at ./client.jl:383
 [13] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [14] invokelatest at ./essentials.jl:711 [inlined]
 [15] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:367
 [16] exec_options(::Base.JLOptions) at ./client.jl:305
 [17] _start() at ./client.jl:484

On the other hand, running the same statement via rcall() seems to work fine.

julia> "α;" |> rcall
"!#03b1;"

julia> ans |> RExpr

α

In the meantime, calling a similar statement can make my REPL stuck indefinitely.

julia> "αα;" |> rcall

# no response
@tomyun
Copy link
Contributor Author

tomyun commented Jun 19, 2020

A bit more testing:

julia> R"α"

α
julia> R"αα"
Error showing value of type RExpr:
ERROR: Reduce:

Declare α operator ?  (Y or N)

Type Y or N


at
Stacktrace:
 [1] ReduceCheck at /Users/tomyun/.julia/packages/Reduce/fWMAZ/src/Reduce.jl:60 [inlined]
 [2] read(::Reduce.PSL) at /Users/tomyun/.julia/packages/Reduce/fWMAZ/src/Reduce.jl:95
 [3] rcall(::RExpr; on::Array{Symbol,1}, off::Array{Symbol,1}) at /Users/tomyun/.julia/packages/Reduce/fWMAZ/src/rexpr.jl:473
 [4] show(::IOContext{REPL.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::RExpr) at /Users/tomyun/.julia/packages/Reduce/fWMAZ/src/rexpr.jl:127
 [5] display(::REPL.REPLDisplay, ::MIME{Symbol("text/plain")}, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:137
 [6] display(::REPL.REPLDisplay, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:141
 [7] display(::Any) at ./multimedia.jl:323
 [8] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [9] invokelatest at ./essentials.jl:711 [inlined]
 [10] print_response(::IO, ::Any, ::Bool, ::Bool, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:161
 [11] print_response(::REPL.AbstractREPL, ::Any, ::Bool, ::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:146
 [12] (::REPL.var"#do_respond#38"{Bool,REPL.var"#48#57"{REPL.LineEditREPL,REPL.REPLHistoryProvider},REPL.LineEditREPL,REPL.LineEdit.Prompt})(::Any, ::Any, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:729
 [13] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [14] invokelatest at ./essentials.jl:711 [inlined]
 [15] run_interface(::REPL.Terminals.TextTerminal, ::REPL.LineEdit.ModalInterface, ::REPL.LineEdit.MIState) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/LineEdit.jl:2354
 [16] run_frontend(::REPL.LineEditREPL, ::REPL.REPLBackendRef) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:1055
 [17] run_repl(::REPL.AbstractREPL, ::Any) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/REPL/src/REPL.jl:206
 [18] (::Base.var"#764#766"{Bool,Bool,Bool,Bool})(::Module) at ./client.jl:383
 [19] #invokelatest#1 at ./essentials.jl:712 [inlined]
 [20] invokelatest at ./essentials.jl:711 [inlined]
 [21] run_main_repl(::Bool, ::Bool, ::Bool, ::Bool, ::Bool) at ./client.jl:367
 [22] exec_options(::Base.JLOptions) at ./client.jl:305
 [23] _start() at ./client.jl:484

@chakravala
Copy link
Owner

Unicode characters are very tricky to support, there is a bit of functionality for it built in, but I don't have the time available to make unicode support more robust. ASCII is recommended.

@tomyun
Copy link
Contributor Author

tomyun commented Jun 20, 2020

That sounds fair. By the way, I came across with your old conversation on this issue and a workaround mentioned there seems to work for me.

julia> codepoint('α')
0x000003b1
julia> "!#03b1;;" |> rcall |> RExpr

α

julia> "!#03b1;!#03b1;;" |> rcall |> RExpr

αα

julia> R"!#03b1;"

α

julia> R"!#03b1;!#03b1;"

αα

@NightMachinery
Copy link

Is this the same bug? It completely breaks Reduce ...

julia> using Reduce
@forReduce (Free CSL version, revision 5286), 01-Mar-20 ...
REPL mode REDUCE initialized. Press } to enter and backspace to exit.

julia> @force using Reduce.Algebra
WARNING: ignoring conflicting import of Algebra.length into Main

julia> int(ℯ^(:x) , :x)
:(ℯ ^ x)

julia> int(ℯ^(:x^2) , :x)
:((-(sqrt(π)) * erf(im * x) * im) / 2)

julia> print(@latex int(ℯ^(:x^2) , :x))
ERROR: LoadError: Reduce:
int(^(e,^($$$;
at line 1

***** Too few right parentheses
Stacktrace:
 [1] ReduceCheck at /Users/evar/.julia/packages/Reduce/HgVTl/src/Reduce.jl:60 [inlined]
 [2] read(::Reduce.PSL) at /Users/evar/.julia/packages/Reduce/HgVTl/src/Reduce.jl:95
 [3] rcall(::RExpr; on::Array{String,1}, off::Array{Symbol,1}) at /Users/evar/.julia/packages/Reduce/HgVTl/src/rexpr.jl:473
 [4] rcall(::RExpr, ::String) at /Users/evar/.julia/packages/Reduce/HgVTl/src/rexpr.jl:488
 [5] parse_switch(::String, ::RExpr; be::Int64) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:343
 [6] r_switch(::String, ::SubString{String}; be::Int64) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:388
 [7] parse_switch(::String, ::RExpr; be::Int64) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:331
 [8] unfold_expr_force(::Symbol, ::Symbol, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:848
 [9] unfold_expr(::Symbol, ::Symbol, ::Expr; force::Bool) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:813
 [10] unfold_expr(::Symbol, ::Symbol, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:808
 [11] unfold(::Symbol, ::Symbol, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:870
 [12] latex(::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:800
 [13] @latex(::LineNumberNode, ::Module, ::Any) at /Users/evar/.julia/packages/Reduce/HgVTl/src/switch.jl:94
in expression starting at REPL[7]:1

julia> print(@latex int(ℯ^(:x^2) , :x) )
ERROR: LoadError: Reduce:
int(^(e,^($$$;
at line 1

***** Too few right parentheses
Stacktrace:
 [1] ReduceCheck at /Users/evar/.julia/packages/Reduce/HgVTl/src/Reduce.jl:60 [inlined]
 [2] read(::Reduce.PSL) at /Users/evar/.julia/packages/Reduce/HgVTl/src/Reduce.jl:95
 [3] rcall(::RExpr; on::Array{String,1}, off::Array{Symbol,1}) at /Users/evar/.julia/packages/Reduce/HgVTl/src/rexpr.jl:473
 [4] rcall(::RExpr, ::String) at /Users/evar/.julia/packages/Reduce/HgVTl/src/rexpr.jl:488
 [5] parse_switch(::String, ::RExpr; be::Int64) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:343
 [6] r_switch(::String, ::SubString{String}; be::Int64) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:388
 [7] parse_switch(::String, ::RExpr; be::Int64) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:331
 [8] unfold_expr_force(::Symbol, ::Symbol, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:848
 [9] unfold_expr(::Symbol, ::Symbol, ::Expr; force::Bool) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:813
 [10] unfold_expr(::Symbol, ::Symbol, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:808
 [11] unfold(::Symbol, ::Symbol, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:870
 [12] latex(::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:800
 [13] @latex(::LineNumberNode, ::Module, ::Any) at /Users/evar/.julia/packages/Reduce/HgVTl/src/switch.jl:94
in expression starting at REPL[8]:1

julia> print(@latex int(ℯ^(:x^2) , :x) ))
ERROR: syntax: extra token ")" after end of expression
Stacktrace:
 [1] top-level scope at REPL[8]:0

julia> print(@latex int(ℯ^(:x^2) , :x) )
ERROR: LoadError: Reduce:
int(^(e,^($$$;
at line 1

***** Too few right parentheses
Stacktrace:
 [1] ReduceCheck at /Users/evar/.julia/packages/Reduce/HgVTl/src/Reduce.jl:60 [inlined]
 [2] read(::Reduce.PSL) at /Users/evar/.julia/packages/Reduce/HgVTl/src/Reduce.jl:95
 [3] rcall(::RExpr; on::Array{String,1}, off::Array{Symbol,1}) at /Users/evar/.julia/packages/Reduce/HgVTl/src/rexpr.jl:473
 [4] rcall(::RExpr, ::String) at /Users/evar/.julia/packages/Reduce/HgVTl/src/rexpr.jl:488
 [5] parse_switch(::String, ::RExpr; be::Int64) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:343
 [6] r_switch(::String, ::SubString{String}; be::Int64) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:388
 [7] parse_switch(::String, ::RExpr; be::Int64) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:331
 [8] unfold_expr_force(::Symbol, ::Symbol, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:848
 [9] unfold_expr(::Symbol, ::Symbol, ::Expr; force::Bool) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:813
 [10] unfold_expr(::Symbol, ::Symbol, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:808
 [11] unfold(::Symbol, ::Symbol, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:870
 [12] latex(::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:800
 [13] @latex(::LineNumberNode, ::Module, ::Any) at /Users/evar/.julia/packages/Reduce/HgVTl/src/switch.jl:94
in expression starting at REPL[10]:1

julia> int(ℯ^(:x^2) , :x)
┌ Info: REDUCE:
│ \begin{displaymath}
│ displaymath
│ \end{displaymath}
│
└ ***  Longer than one character identifiers used   displaymath
ERROR: Reduce: Nested :incomplete block structure not supported

$(Expr(:incomplete, "incomplete: \"begin\" at none:1 requires end"))
Stacktrace:
 [1] show_expr(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:668
 [2] show_expr(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Tuple{Expr}) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:729
 [3] unparse(::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/parser.jl:772
 [4] |> at ./operators.jl:823 [inlined]
 [5] RExpr at /Users/evar/.julia/packages/Reduce/HgVTl/src/rexpr.jl:42 [inlined]
 [6] ^(::Irrational{:ℯ}, ::Expr) at /Users/evar/.julia/packages/Reduce/HgVTl/src/args.jl:158
 [7] top-level scope at REPL[11]:1

julia>

@chakravala
Copy link
Owner

Have you tried using Reduce.Reset() to reset the REDUCE instance?

@NightMachinery
Copy link

@chakravala commented on Jul 30, 2020, 6:14 PM GMT+4:30:

Have you tried using Reduce.Reset() to reset the REDUCE instance?

No, I just restarted Julia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants