Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing problem with nested splatting named tuple constructor in a function call #35201

Closed
bkamins opened this issue Mar 21, 2020 · 0 comments · Fixed by #35202
Closed

Parsing problem with nested splatting named tuple constructor in a function call #35201

bkamins opened this issue Mar 21, 2020 · 0 comments · Fixed by #35202
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@bkamins
Copy link
Member

bkamins commented Mar 21, 2020

In the code below definitions f1 and f2 should be equivalent I think.
However, f1 is a syntax error, while f2 works as expected.

julia> h(x; k=1) = (x, k)
h (generic function with 1 method)

julia> f1(c) = h((;c...), k=true)
ERROR: syntax: "..." expression outside call
Stacktrace:
 [1] top-level scope at REPL[8]:1

julia> f2(c) = (nt=(;c...); h(nt, k=true))
f2 (generic function with 1 method)

julia> f2(Dict(:a=>1, :b=>2))
((a = 1, b = 2), true)

It seems that a parser does not correctly recognize that ... in this case is used in a nested NamedTuple constructor call within a call to h.

The problem seems to be present only if the call involves keyword arguments, so e.g.

julia> f1(c) = h((;c...), true)
f1 (generic function with 1 method)

parses correctly.

Also

julia> f1(c) = h(;c..., k=true)
f1 (generic function with 1 method)

parses, but it gives a different definition of course.

@JeffBezanson JeffBezanson self-assigned this Mar 21, 2020
@JeffBezanson JeffBezanson added the bug Indicates an unexpected problem or unintended behavior label Mar 21, 2020
KristofferC pushed a commit that referenced this issue Mar 23, 2020
oxinabox pushed a commit to oxinabox/julia that referenced this issue Apr 8, 2020
ravibitsgoa pushed a commit to ravibitsgoa/julia that referenced this issue Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants