-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorfeatureIndicates new feature / enhancement requestsIndicates new feature / enhancement requestsparserLanguage parsing and surface syntaxLanguage parsing and surface syntax
Description
It would be nice if the long form anonymous functions would support return type declarations akin to named functions. That is, it'd be nice if the following converted and asserted the return type is T
:
julia> function(x, y)::T
return x*y
end
ERROR: syntax: expected "(" in function definition
Note that this appears to work with one argument, but it's bugged and actually applying the type declaration to the argument instead of the function's return:
julia> f = function(x)::Int
x/2
end
#11 (generic function with 1 method)
julia> f(2.0)
ERROR: MethodError: no method matching (::getfield(Main, Symbol("##11#12")))(::Float64)
Closest candidates are:
#11(::Int64) at REPL[41]:2
Stacktrace:
[1] top-level scope at none:0
julia> :(function(x)::Int
x/2
end)
:(function (x::Int,)
#= REPL[47]:2 =#
x / 2
end)
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorfeatureIndicates new feature / enhancement requestsIndicates new feature / enhancement requestsparserLanguage parsing and surface syntaxLanguage parsing and surface syntax