Skip to content

Improve error message when method calls missed some commas in Julia 1.10 #52285

Closed
@Tortar

Description

@Tortar

In Julia 1.10-rc1:

julia> f(x, y, z) = x+y+z
f (generic function with 1 method)

julia> f(3,4 5)
ERROR: ParseError:
# Error @ REPL[2]:1:7
f(3,4 5)
#     ╙ ── Expected `)`
Stacktrace:
 [1] top-level scope
   @ none:1

Contrast this with Python 3.10 which instead:

>>> def f(x,y,z): return x+y+z
... 
>>> f(3,4 5)
  File "<stdin>", line 1
    f(3,4 5)
        ^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?

The error message of Python seems better, can we change the Julia message to something similar? Probably multiple dispatch makes this trickier though.

Indeed it was better in Julia 1.9

julia> f(3,4 5)
ERROR: syntax: missing comma or ) in argument list
Stacktrace:
 [1] top-level scope
   @ none:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    error messagesBetter, more actionable error messagesparserLanguage parsing and surface syntax

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions