-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
unary operators eat function call parentheses when argument is a tuple #12755
Labels
parser
Language parsing and surface syntax
Comments
Here is a test case: Compare the values of
and
which differ, i.e. |
Yes, I think this can/should be fixed. |
timholy
added a commit
that referenced
this issue
Aug 23, 2015
@timholy What was the intention of the revert, should this be reopened? |
Thanks. |
JeffBezanson
changed the title
Unary operators eat function call parentheses
unary operators eat function call parentheses when argument is a tuple
Aug 26, 2015
Seems be fixed nowadays: julia> +((1,2))
ERROR: MethodError: no method matching +(::Tuple{Int64,Int64})
Closest candidates are:
+(::Any, ::Any, ::Any, ::Any...) at operators.jl:538
+(::Pkg.Resolve.FieldValue, ::Pkg.Resolve.FieldValue) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.5/Pkg/src/Resolve/fieldvalues.jl:43
+(::Float32, ::Float32) at float.jl:400
...
Stacktrace:
[1] top-level scope at REPL[13]:1 |
Reference: #26154 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is Julia 0.4-dev in the Jupyter REPL.
This calls
f
with two arguments:f(1,2)
This calls
f
with one argument:f((1,2))
(the argument is a tuple).This calls
+
with two arguments:+(1,2)
But this doesn't work:
+((1,2))
-- it still calls+
with two arguments instead of a tuple. This is very counter-intuitive, and I argue it is wrong.Work-arounds are this:
(+)((1,2))
(put operator into parenthesis) or this:+((1,2),)
(enforce a single-argument function call via a trailing comma).(This trailing-comma syntax is documented for tuples; is it also intended and/or documented for function calls?)
The same issue exists for
-
,!
, and~
.The text was updated successfully, but these errors were encountered: