Skip to content

Commit 74cead1

Browse files
committed
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 b7af64f commit 74cead1

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
@@ -1095,7 +1095,7 @@ end
10951095
end
10961096

10971097
@nospecs function _getfield_tfunc(𝕃::AnyMustAliasesLattice, s00, name, setfield::Bool)
1098-
return _getfield_tfunc(widenlattice(𝕃), widenmustalias(s00), name, setfield)
1098+
return _getfield_tfunc(widenlattice(𝕃), widenmustalias(s00), widenmustalias(name), setfield)
10991099
end
11001100

11011101
@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
@@ -2569,6 +2569,14 @@ Base.return_types(intermustalias_edgecase, (Any,); interp=MustAliasInterpreter()
25692569
intermustalias_edgecase(x)
25702570
end |> only === Core.Compiler.InterMustAlias
25712571

2572+
@test Base.infer_return_type((AliasableField,Integer,); interp=MustAliasInterpreter()) do a, x
2573+
s = (;x)
2574+
if getfield(a, :f) isa Symbol
2575+
return getfield(s, getfield(a, :f))
2576+
end
2577+
return 0
2578+
end == Integer
2579+
25722580
function f25579(g)
25732581
h = g[]
25742582
t = (h === nothing)

0 commit comments

Comments
 (0)