I've been using Julia for a month now and switch between many languages. Two of the other langauges i use quite a bit are SQL and python, languages that support single-quote strings. Obviously i know strings are defined using " double-quotes in Julia, but sometimes I slip up and define a string using ' rather than ". It would be nice in these situations to return a slightly more useful error than the current one.
'this is intended to be string' #< throws ERROR: syntax: Invalid character literal
improvement
'this is intended to be string' # ERROR: syntax: char length greater than 1 (or something)
It's not really about the char length though:
julia> '\u2200'
'∀': Unicode U+2200 (category Sm: Symbol, math)
It is about the validity.
yea, I agree here that char is not length dependent. I made my suggestion too quickly and more as a general idea.
Maybe something like invalid character - contains multiple characters or something like that would be more appropriate.
The main point I want to stress is now that I've gone through this, I'll know what ERROR: syntax: Invalid character literal means when I run into it in the future, but the amount of time and energy it took to figure this out the first time could have been minimized with a more informative error message. And, as more people move to the language with, I'm sure others will fall into this same hole.
On a maybe related note. Did you know that julia never finishes evaluating this char ->'\'. I know it's. used as escaping but this may be unintended behavior. If so, I'll create a separate issue for it.
'\' is just incomplete input, since we haven't seen the closing ' yet. It behaves just like f( or '.
For the original issue, it would be easy to give a more specific message like "character literal contains multiple characters".
Most helpful comment
'\'is just incomplete input, since we haven't seen the closing'yet. It behaves just likef(or'.For the original issue, it would be easy to give a more specific message like "character literal contains multiple characters".