-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Parse errors on anonymous function return type annotations #23072
Comments
|
Also, since the function body in Also note that |
But what about |
We cannot write anonymous functions with return type, because it will cause parsing ambiguity. See JuliaLang/julia#23072.
This impacts opaque closures since then you don't have a way to specify the return type. f2 = Base.Experimental.@opaque function (x::Float64, y::Float64)
2x + y
end works, but f2 = Base.Experimental.@opaque function (x::Float64, y::Float64)::Float64
2x + y
end hits this error. |
actually, julia> function (x, y)::Float32
return x
end
ERROR: syntax: ambiguous signature in function definition. Try adding a comma if this is a 1-argument anonymous function.
Stacktrace:
[1] top-level scope
@ none:1
julia> function (x, )::Float32
return x
end
ERROR: syntax: ambiguous signature in function definition. Try adding a comma if this is a 1-argument anonymous function. I'm not sure what's going on here |
Pretty sure Jeff meant that as "can be made to work". The current parser doesn't handle either case. |
ah
confused my |
Also related (as noted by @pfitzseb):
The text was updated successfully, but these errors were encountered: