Skip to content

Commit

Permalink
inference: add missing MustAlias widening in _getfield_tfunc (#54996
Browse files Browse the repository at this point in the history
)

Otherwise it may result in missing `⊑` method error in uses cases by
external abstract interpreters using `MustAliasesLattice` like JET.
  • Loading branch information
aviatesk authored Jul 2, 2024
1 parent 6cf3a05 commit 7579659
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/compiler/tfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ end
end

@nospecs function _getfield_tfunc(𝕃::AnyMustAliasesLattice, s00, name, setfield::Bool)
return _getfield_tfunc(widenlattice(𝕃), widenmustalias(s00), name, setfield)
return _getfield_tfunc(widenlattice(𝕃), widenmustalias(s00), widenmustalias(name), setfield)
end

@nospecs function _getfield_tfunc(𝕃::PartialsLattice, s00, name, setfield::Bool)
Expand Down
8 changes: 8 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2565,6 +2565,14 @@ Base.return_types(intermustalias_edgecase, (Any,); interp=MustAliasInterpreter()
intermustalias_edgecase(x)
end |> only === Core.Compiler.InterMustAlias

@test Base.infer_return_type((AliasableField,Integer,); interp=MustAliasInterpreter()) do a, x
s = (;x)
if getfield(a, :f) isa Symbol
return getfield(s, getfield(a, :f))
end
return 0
end == Integer

function f25579(g)
h = g[]
t = (h === nothing)
Expand Down

0 comments on commit 7579659

Please sign in to comment.