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

more specific location for syntax errors #6179

Closed
maximsch2 opened this issue Mar 15, 2014 · 8 comments
Closed

more specific location for syntax errors #6179

maximsch2 opened this issue Mar 15, 2014 · 8 comments
Labels
error handling Handling of exceptions by Julia or the user

Comments

@maximsch2
Copy link
Contributor

test.jl:

function test(a, b)
  c = 0
  d = 3
  d = d + a(b, d]
end

julia test.jl:

ERROR: syntax: unexpected "]" in argument list in include_from_node1 at loading.jl:120 while loading test.jl, in expression starting on line 1

It would be better if the error will be point out more precisely (instead of just pointing at the beginning of the function).

@StefanKarpinski
Copy link
Member

Unless this is accompanied by a pull request to improve the parser, I'm going to close this as busywork that will most likely fall on @JeffBezanson. An unbounded amount of time and effort can be put into making the parser handle syntax errors better, but it's a matter of diminishing returns. That's not to say that improvements aren't welcomed – we will happily merge pull requests that improve error messages!

@stevengj
Copy link
Member

I'm re-opening this. Duplicates of this issue keep appearing because Julia's syntax errors are often inordinately vague at the moment; we aren't anywhere close to the point of diminishing returns yet. We need an issue as a place to both centralize complaints and to track work that is being done to improve matters.

@stevengj stevengj reopened this Apr 25, 2014
@tkelman
Copy link
Contributor

tkelman commented Apr 25, 2014

#4744 ?

@stevengj
Copy link
Member

@tkelman, that issue is for generic improvements to error messages; this one is specific to line numbers.

@timholy
Copy link
Member

timholy commented May 15, 2014

Ooh! This is going to be really nice! I added a NEWS.md item.

@stevengj
Copy link
Member

Re-opening this issue due to @dfagnan's example in #8828, which reports an error on "line 1" no matter where in the for loop you put the problematic expression (even dozens of lines later).

for i=1:10
    if false |           # Should error on line 2.
        continue
    end
end

@oscardssmith
Copy link
Member

I just ran into this. I'm definitely not the most experienced Julian, but we have to be able to do better than

ERROR: syntax: missing comma or ) in argument list
Stacktrace:
 [1] top-level scope at none:1

for

function foo()
           x=1
           bar(a b)
end

If you're typing it in line by line, the experience is fine since the error comes right after you hit the offending line, but if you're copy-pasting code in, not having any indication what line was the problem is really annoying.

@vtjnash vtjnash closed this as completed Jan 31, 2024
@vtjnash
Copy link
Member

vtjnash commented Jan 31, 2024

julia> function foo()
                  x=1
                  bar(a b)
       end

ERROR: ParseError:
# Error @ REPL[1]:3:18
           x=1
           bar(a b)
#                ╙ ── Expected `)`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Handling of exceptions by Julia or the user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants