-
-
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
Constant propogation through slurping #26050
Labels
compiler:inference
Type inference
Comments
It would be useful to post a complete test case here. |
Base.@pure argtail(x, rest...) = rest
tail(x) = argtail(x...)
getindex_unrolled(into::Tuple{}, switch::Tuple{}) = ()
getindex_unrolled(into, switch::Tuple{}) = ()
getindex_unrolled(into::Tuple{}, switch) = ()
function getindex_unrolled(into, switch)
next = getindex_unrolled(tail(into), tail(switch))
if first(switch)
(first(into), next...)
else
next
end
end
test() = getindex_unrolled((1, "b", 3.0), (true, false, true))
Test.@inferred test() This only works if |
Solved by #26826? |
No, that PR doesn't include detection that |
Closed by #29264. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recurring through tuples with
first
andBase.tail
is incredibly useful but tail doesn't do constant propagation. I tracked the issue down toargtail
in Base, which needs a pure annotation to do constant propagation correctly.In fact, constant propagation never seems to survive slurping without pure annotations. This seems like a useful feature to have.
The text was updated successfully, but these errors were encountered: