-
-
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
type inference of tuple access across function boundary #21341
Comments
I asked this identical question on the message boards, see some useful comments and basically the answer here. Essentially this doesn't and isn't supposed to currently work. You can use Val types as a workaround if you need type stability. NamedTuples.jl might also work depending what you're trying to do. |
Related: #5560 Basically, it is difficult to do this efficiently since we can't analyze every function body for every constant value. |
More discussion of this in #17880 |
I see thanks for the links both of you. I think I have read all links carefully, but I think no one suggested the following (because the cases were different): |
This is only known after inference has finished. Indeed, it is exactly the job of inference to compute this. |
Mh. First to be clear I mean "only one method" not "one applicable method". My reasoning was that before inference runs I already have access to all generic functions that are called (from a user perspective I should be able to call |
Until you've run inference, you don't know what |
I see. Thanks for pointing this out. |
Closing as dup (or very similar) to #5560 |
Accessing the
n
-th field of a tuple via the[]
operator is type stable in casen
is a literal. However as soon as I wrap the access into a function, type inference fails even if I annotate the function with@inline
.Version:
Note that this also occurs on a very recent master.
The text was updated successfully, but these errors were encountered: