-
-
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
Allow return type declaration for generated function #21322
Comments
I see the problem, but currently return type declarations don't really work that way --- putting |
#12783 is related; also about sorting out which stage things belong to. |
Given that we add type assertion to after the convert we should be able to infer? |
Yes, but if the argument type to the generated function isn't known at compile time, we can't call the generator, so there's no function body to look at. |
Ok. I was assuming the representation/lowering of return type declaration will need changing for generated function since merely an automatic convertion doesn't seem to be too useful for generated function when the user can easily achieve this when generating the code. |
Given that the other type annotations in the function signature are used for dispatch, which means they're considered to mean what they mean at application time, it seems sane to me that the return type annotation would mean that as well. In which case it would presumably mean that each return point is automatically rewritten with the appropriate convert-assert, no? |
Runtime dispatch to a generated function is always typed as
::Any
, for good reason:If we could specify the return type
@generated function foo(obj)::Bool
, that would help fix common cases (eg. predicates). Currently, this syntax is valid, but it specifies the return type of the expansion, which is useless.The text was updated successfully, but these errors were encountered: