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

Return type assertions don't work with anonymous functions. #24469

Closed
Ismael-VC opened this issue Nov 4, 2017 · 2 comments
Closed

Return type assertions don't work with anonymous functions. #24469

Ismael-VC opened this issue Nov 4, 2017 · 2 comments

Comments

@Ismael-VC
Copy link
Contributor

Anonymous functions don't accept return type assertions:

julia> (((x::T, y::T)::T) where {T<:Int}) -> x + y                   
ERROR: syntax: "(x::T,y::T)" is not a valid function argument name   

julia> function (((x::T, y::T)::T) where {T<:Int}); return x + y; end
ERROR: syntax: expected "(" in function definition

But this work:

julia> ((foo(x::T, y::T)::T) where {T<:Int}) = x + y                    
foo (generic function with 1 method)                                    

julia> function ((foo(x::T, y::T)::T) where {T<:Int}); return x + y; end
foo (generic function with 1 method)
@mauro3
Copy link
Contributor

mauro3 commented Nov 5, 2017

Dup of #23072

(Also, note that it is a return type conversion, not assertion.)

@Ismael-VC
Copy link
Contributor Author

Thanks for correcting the terminology.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants