-
-
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
Return type annotations fail to parse on functions with no body #19106
Comments
This won't do what you want (see #16432 (comment)), but we can give a better error message. |
I don't think any of these should error on definition. Given: julia> function g() end
g (generic function with 1 method)
julia> @code_lowered g()
LambdaInfo template for g() at REPL[6]:1
:(begin
nothing
return
end) julia> function f()::Int
nothing
end
f (generic function with 1 method)
julia> @code_lowered f()
LambdaInfo template for f() at REPL[5]:2
:(begin
nothing
return (Base.convert)(Main.Int,Main.nothing)
end) julia> function h()::Int
nothing
return
end
h (generic function with 1 method)
julia> @code_lowered h()
LambdaInfo template for h() at REPL[9]:2
:(begin
nothing
SSAValue(0) = Main.Int
Main.nothing # line 3:
return (Core.typeassert)((Base.convert)(SSAValue(0),nothing),SSAValue(0))
end) I would expect a call to this function: function i()::Int
end to lower to either: :(begin
SSAValue(0) = Main.Int
Main.nothing
return (Core.typeassert)((Base.convert)(SSAValue(0),nothing),SSAValue(0))
end) or :(begin
return (Base.convert)(Main.Int,Main.nothing)
end) |
@JeffBezanson this works, but not sure if there are other cases to handle:
|
The last line of that patch doesn't make sense; it says to return the value |
fix #19106, ret type decl on function with empty body
Is a backport possible? |
#19114 is already labeled. Be careful to declare your minimum version dependency as 0.5.1 if you want to rely on this working though. |
The text was updated successfully, but these errors were encountered: