Skip to content
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

Fix fieldtype_tfunc for union types #41667

Merged
merged 3 commits into from
Jul 22, 2021
Merged

Conversation

martinholters
Copy link
Member

On master:

julia> T = Union{Tuple{Val}, Tuple{Tuple}}
Union{Tuple{Val}, Tuple{Tuple}}

julia> fieldtype(T, 1)
Union{Tuple, Val}

julia> Core.Compiler.fieldtype_tfunc(Core.Const(T), Core.Const(1))
Union{Type{Val}, Type{Tuple}} # should be Type{Union{Tuple, Val}}

I tried to be conservative here in the sense that in cases where this PR changes the result, it is actually for the better, but there may be cases left where fieldtype_tfunc remains unsound for Type{Union{...}} input.

Fixes #40177.

@martinholters martinholters added bugfix This change fixes an existing bug compiler:inference Type inference labels Jul 21, 2021
base/compiler/tfuncs.jl Outdated Show resolved Hide resolved
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Jul 21, 2021
@martinholters
Copy link
Member Author

I think the CI failure on FreeBSD is unrelated/also seen elsewhere? Then this should be good to go.

@martinholters martinholters merged commit 2c02de8 into master Jul 22, 2021
@martinholters martinholters deleted the mh/fix-fieldtype-tfunc branch July 22, 2021 05:41
@martinholters martinholters removed the merge me PR is reviewed. Merge when all tests are passing label Jul 22, 2021
KristofferC pushed a commit that referenced this pull request Jul 26, 2021
Co-authored-by: Jameson Nash <vtjnash@gmail.com>
(cherry picked from commit 2c02de8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug compiler:inference Type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A "fatal error in type inference (type bound)" in Julia 1.6.0-rc3 and 1.7.0-DEV.749
4 participants