JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.42k stars 5.45k forks source link

Parsing error with anonymous function #20844

Open rborder opened 7 years ago

rborder commented 7 years ago

Getting the following error

julia> halfTo = function(k) (1//2)^k end

WARNING: deprecated syntax "k (".
Use "k(" instead.
ERROR: syntax: "^" is not a unary operator

though the following works fine:

julia> plusOne = function(k) 1+k end
(anonymous function)

I know it's inelegant code, but either they should both work or both not work.

martinholters commented 7 years ago

On master, the deprecation is now an error, but the problem as such persists. Note that function() () end errors while function(); () end works (anonymous function that returns an empty tuple).

adienes commented 1 year ago

btw, this discrepancy still exists on master. should probably get bug label