ERROR: syntax: "\" is not a unary operator

I am currently working through the Introduction to Julia course and I am having trouble using the :smiley_cat: syntax. When I try to assign a value to it in Jupyter lab and the repl I get the following error message:

ERROR: syntax: “\” is not a unary operator

When I try to use it in nteract I get:

syntax: “\” is not a unary operator

Stacktrace:
[1] top-level scope at In[3]:3
[2] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091

I am on windows using JuliaPro 1.5.3-1 installation. Probably unrelated but I also get an error using tab auto fill on Jupyter Lab.

1 Like

Can you post the actual code that generates the error? Otherwise it’s not obvious how you’re using \ and generating this error. BTW, you can use ``` to make your code format nicely: PSA: how to quote code with backticks

1 Like

The key to getting the emoji/latex unicode symbols is tab completion. You type \:smile_cat: and then hit TAB. It’s not a Julia syntax — it’s an editor/repl tab completion feature.

1 Like

Yeah, no problem. Quite new to this so hopefully I have followed the formatting correctly :slight_smile:
So in nteract:

\:smiley_cat: = 5
​
syntax: "\" is not a unary operator

Stacktrace:
 [1] top-level scope at In[1]:1
 [2] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091

I have tried to fix the issue by doing a fresh install and updating all the packages but still seem to get his error.

So when I try using tab I get this error on Jupyter Lab:

syntax: "\" is not a unary operator

Stacktrace:
 [1] top-level scope at In[2]:2
 [2] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091
KERNEL EXCEPTION
BoundsError: attempt to access String
  at index [1:22]

Stacktrace:
 [1] checkbounds at .\strings\basic.jl:214 [inlined]
 [2] getindex(::String, ::UnitRange{Int64}) at .\strings\string.jl:248
 [3] complete_request(::ZMQ.Socket, ::IJulia.Msg) at C:\Users\angus\.julia\packages\IJulia\IDNmS\src\handlers.jl:115
 [4] #invokelatest#1 at .\essentials.jl:710 [inlined]
 [5] invokelatest at .\essentials.jl:709 [inlined]
 [6] eventloop(::ZMQ.Socket) at C:\Users\angus\.julia\packages\IJulia\IDNmS\src\eventloop.jl:8
 [7] (::IJulia.var"#15#18")() at .\task.jl:356

However I think this maybe an issue with Jupyter Lab specifically as it did work on Jupyter Notebook but I still got the syntax error.
Pressing tab on nteract does nothing and on the repl it gives me suggestions but I still get the error:

syntax: "\" is not a unary operator

I have tried updating IJulia specifically to try to fix it but doesn’t seem to have an effect.

Let’s focus on the REPL for now. Here’s what happens for me:

I type \:smiley_cat: and I see:

julia> \:smiley_cat:

I then press Tab and I see:

julia> 😺

as expected. What happens for you?

Ah okay, that is working for me. I didn’t realise I had to type it all out explicitly and then press tab for the REPL. Thank you

1 Like

Right–you can still use Tab to complete a partially-typed entry like this, but you still have to press Tab again to actually convert it into the desired Unicode character. Glad it’s working for you now!

4 Likes

the day I learnt something new about Julia and the double tab :upside_down_face: