JuliaLang / JuliaLang/JuliaSyntax.jl

Better error for trailing commas in `using`

Open
#108 2 comments 0 reactions 0 assignees View on GitHub
error messages
Dominant language
Julia
Stars
293
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Leaving a trailing comma after the last element of `using` is a mistake I've made a few times. The parser only catches this error later, resulting in a fairly poor error message. For example, it can gobble up the `function` keyword in the next part of the file:

```julia
julia> using A: b,

function foo()
end

ERROR: ParseError:
Error: extra tokens after end of expression
@ REPL[4]:3:9
using A: b,

function foo()
--------^^^^^^---
end
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the Julia REPL example with a trailing comma in `using A: b,` followed by `function foo()`. Start by tracing how the parser handles the `using` statement and the following `function` keyword. Done means the trailing comma produces a direct, useful parse error instead of consuming the next construct and reporting extra tokens later.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.