Skip to content

Better error message for invalid syntax followed by valid syntax #318

Open
@LilithHafner

Description

@LilithHafner
julia> import a, b, c=d e, f, g, h
ERROR: ParseError:
# Error @ REPL[50]:1:17
import a, b, c=d e, f, g, h
#               └─────────┘ ── extra tokens after end of expression

julia> 1 = 2 3
ERROR: ParseError:
# Error @ REPL[58]:1:6
1 = 2 3
#    └┘ ── extra tokens after end of expression

I believe that the "extra tokens after end of expression" error should only occur if the expression preceding the extra tokens is complete and valid.

Maybe the real issue here is that this should throw?

julia> Meta.parse("import a = 1")
:(import a = 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    error messagesBetter, more actionable diagnostics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions