Skip to content

unexpected "end" error message sometimes seems to be not true #45791

@StevenWhitaker

Description

@StevenWhitaker

I'm opening this issue based on a question on discourse.

Consider the following code:

if true
    x +
end

This will result in (at least on Julia 1.7.0)

ERROR: syntax: unexpected "end"

This error makes sense from the parser's perspective: the end is unexpected because a second argument to + is expected. But from the programmer's perspective, one could argue that the end is exactly where one would expect. The real error is that the + function call is missing an argument.

Could the error message be changed to point to the missing argument instead? Something like

ERROR: syntax: attempted to call an infix operator with just one argument

The unexpected "end" error also occurs when x + is replaced with, e.g., f(x,. In this case, a better error message might be something like

ERROR: syntax: incomplete function call - missing closing parenthesis ")"

Metadata

Metadata

Assignees

No one assigned

    Labels

    error handlingHandling of exceptions by Julia or the userparserLanguage parsing and surface syntax

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions