No line number for: syntax: unexpected ")"

Is there a way to get syntax messages like this to show a line number?

syntax: unexpected “)”

from a technical point of view, no, because you can’t be sure which line is actually “missing” a ), but I agree this is very annoying

2 Likes

Presumably it could at least show the line number for the unmatched (?

1 Like

Actually if it’s an unexpected ) then it is known on which line that occurs.

4 Likes

It is shown for me in the stacktrace in Julia 1.5:

shell> cat /tmp/tmp.jl
(1+2))

julia> include("/tmp/tmp.jl");
ERROR: LoadError: syntax: extra token ")" after end of expression
Stacktrace:
 [1] top-level scope at /tmp/tmp.jl:1
 [2] include(::String) at ./client.jl:457
 [3] top-level scope at REPL[72]:1
in expression starting at /tmp/tmp.jl:1
4 Likes

I’m using 1.4.2. Maybe its a Jupyter thing? Below is my output. Other errors are flagged with a line number in the stacktrace, but extra ( or [ are not.

syntaxFlag

1 Like

I have also perceived this behavior, and it is very annoying.

1 Like

Yes, perhaps open an issue for Jupyter.

1 Like

It’s already fixed if you use IJulia with Julia 1.5:


With previous Julia versions, we had to re-implement include_string in order to do the soft-scoping transformation, and lost some line-number information in the process.

5 Likes

Thanks. I’ll be upgrading today.