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

Support keyword args in anonymous functions with optional positional args #26916

Closed
AndiMD opened this issue Apr 27, 2018 · 3 comments
Closed
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior compiler:lowering Syntax lowering (compiler front end, 2nd stage)

Comments

@AndiMD
Copy link

AndiMD commented Apr 27, 2018

The following behavior seems erroneous, or at least confusing to me:

These work:
f(x=1;y=2)=x+y
(x;y=2)->x+y
(x=1,y=2)->x+y

This errors:
(x=1;y=2)->x+y

ERROR: syntax: invalid assignment location "begin
x=1
y=2
end"

versioninfo()
Julia Version 0.6.2
Commit d386e40 (2017-12-13 18:08 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, skylake)

@Keno Keno added compiler:lowering Syntax lowering (compiler front end, 2nd stage) bug Indicates an unexpected problem or unintended behavior labels Apr 27, 2018
@mbauman mbauman changed the title Anonymous function: syntax error Support keyword args in short-form anonymous functions Apr 27, 2018
@mbauman
Copy link
Member

mbauman commented Apr 27, 2018

For reference, anonymous functions created with the function keyword were fixed in #19744. Looks like we still need to fix this case.

@AndiMD
Copy link
Author

AndiMD commented Apr 28, 2018

@mbaumann: Unfortunately, there still seems to be an issue when the first parameter has a default value:

f = function(x=1; kwargs...) return x; end
f = function(x=1; y=2) return x+y; end

@mbauman
Copy link
Member

mbauman commented Apr 30, 2018

Ah, I see now. Thanks for the correction.

@mbauman mbauman changed the title Support keyword args in short-form anonymous functions Support keyword args in anonymous functions with optional positional args Apr 30, 2018
@JeffBezanson JeffBezanson self-assigned this May 3, 2018
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 compiler:lowering Syntax lowering (compiler front end, 2nd stage)
Projects
None yet
Development

No branches or pull requests

4 participants