-
-
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
Can't infer types of elements of named tuples under getindex #24441
Comments
@vtjnash, I believe you've done some constant prop work that might soon help here? |
That would be even better :) I changed the OP to wrap in a function to |
That's the only way this could work. Note that the julia> f(x) = x.a
f (generic function with 1 method)
julia> @code_warntype f(nt)
Variables:
x::NamedTuple{(:a, :b),Tuple{Int64,Float64}}
Body:
begin
return (Core.getfield)(x::NamedTuple{(:a, :b),Tuple{Int64,Float64}}, :a)::Int64
end::Int64 |
You can usually get around constant propagation issues by wrapping things in a type. So |
Yes, you can definitely work around this in a variety of ways - it's just that intuitively we can use |
Duplicate of #24011 |
See PR #24362 |
I had hoped that indexing a named tuple (#22194) with a
Symbol
would be a type-inferrable operation. I'm guessing that a tfunc or whatever, like forTuple
, may be needed here.The text was updated successfully, but these errors were encountered: