JuliaLang / JuliaLang/JuliaSyntax.jl

Parsing/Lowering of `t[i...; kw...]` fails

Open
#579 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Julia
Stars
293
Forks
50
PR merge metrics
No merged PRs in 30d

Description

If we define `Base.getindex(t::MyType, i...; kw...)` we can use the syntax `t[a=1]` and `t[1, a=1]` (they work as expected), but not `t[; a=1]` or `t[1; a=1]`, whose parsing or lowering fails

Demo:
```julia
julia> struct MyType end; Base.getindex(::MyType, i...; kw...) = (i, kw)

julia> t[; a=1]
ERROR: ParseError:
# Error @ REPL[1]:1:5
t[; a=1]
# └─┘ ── Expected `]`
Stacktrace:
[1] top-level scope
@ none:1

julia> t[1; a=1]
ERROR: syntax: misplaced assignment statement in "(t 1 (= a 1))" around REPL[2]:1
Stacktrace:
[1] top-level scope
@ REPL[2]:1
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.