Skip to content

Commit 7579659

Browse files
authored
inference: add missing MustAlias widening in _getfield_tfunc (#54996)
Otherwise it may result in missing `⊑` method error in uses cases by external abstract interpreters using `MustAliasesLattice` like JET.
1 parent 6cf3a05 commit 7579659

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

base/compiler/tfuncs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ end
10981098
end
10991099

11001100
@nospecs function _getfield_tfunc(𝕃::AnyMustAliasesLattice, s00, name, setfield::Bool)
1101-
return _getfield_tfunc(widenlattice(𝕃), widenmustalias(s00), name, setfield)
1101+
return _getfield_tfunc(widenlattice(𝕃), widenmustalias(s00), widenmustalias(name), setfield)
11021102
end
11031103

11041104
@nospecs function _getfield_tfunc(𝕃::PartialsLattice, s00, name, setfield::Bool)

test/compiler/inference.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,6 +2565,14 @@ Base.return_types(intermustalias_edgecase, (Any,); interp=MustAliasInterpreter()
25652565
intermustalias_edgecase(x)
25662566
end |> only === Core.Compiler.InterMustAlias
25672567

2568+
@test Base.infer_return_type((AliasableField,Integer,); interp=MustAliasInterpreter()) do a, x
2569+
s = (;x)
2570+
if getfield(a, :f) isa Symbol
2571+
return getfield(s, getfield(a, :f))
2572+
end
2573+
return 0
2574+
end == Integer
2575+
25682576
function f25579(g)
25692577
h = g[]
25702578
t = (h === nothing)

0 commit comments

Comments
 (0)