-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Better line info for "missing comma or ) in argument list" error #16163
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
Comments
Dup of #15643 |
That one has the title "bad stack trace for errors in macros". This example has no macros. Should the title in #15643 be updated? |
Looks like a different issue to me. This one is about syntax error locations. |
Wow, that is some clang level beauty right there. |
The README has instructions: https://github.com/JuliaLang/JuliaParser.jl#using-juliaparser-as-your-primary-parser |
Here is another example from a typo I made: # test.jl
module Test
function filler()
blabla
end
typealias a = Float64
end # module julia> include("/home/kristoffer/Documents/test.jl")
ERROR: LoadError: syntax: unexpected "="
in include_from_node1(::String) at ./loading.jl:426
in eval(::Module, ::Any) at ./boot.jl:230
while loading /home/kristoffer/Documents/test.jl, in expression starting on line 1 |
Another one: module M
function f()
while true
if x == 0 && y == 0
a = 1
if x == 1 && z == 1
a = 2
end
end
end
end This gives |
I think the best way to give better error messages is probably to consider indentation. To me that suggests bailing out on a parse when there's an error and reparsing the input with a parser that is slower and tracks extra information like indentation and gives really high quality messages. |
Would be awesome if we could have https://github.com/KristofferC/OhMyREPL.jl replace the default |
Already in progress: https://github.com/Keno/FancyDiagnostics.jl |
This is closed in julia 1.5. The first example gives: julia> include("test.jl")
ERROR: LoadError: syntax: missing comma or ) in argument list
Stacktrace:
[1] top-level scope at /home/user/Documents/Programmieren/julia_projects/tmp/test.jl:11
[2] include(::String) at ./client.jl:457
[3] top-level scope at REPL[1]:1
in expression starting at /home/user/Documents/Programmieren/julia_projects/tmp/test.jl:11 This is the line directly after the missing comma. |
JuliaSyntax handles the first problem:
The missing end message is still not optimal. Not sure if there is actually a way to improve this. |
Putting this in a file and
include
it:gives the error message:
Is there anyway the line info could be a bit more specific than just the line of the start of the enclosing function?
The text was updated successfully, but these errors were encountered: