From baed6cd18c95dc3b0bf120c0da378f3de1277f00 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Tue, 2 Jul 2024 16:42:09 +0900 Subject: [PATCH] inference: add missing `MustAlias` widening in `_getfield_tfunc` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise it may result in missing `⊑` method error in uses cases by external abstract interpreters using `MustAliasesLattice` like JET. --- base/compiler/tfuncs.jl | 2 +- test/compiler/inference.jl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/base/compiler/tfuncs.jl b/base/compiler/tfuncs.jl index b069e09214bab..28e883d83312c 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -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) diff --git a/test/compiler/inference.jl b/test/compiler/inference.jl index 6fe050bbd5935..8b0c6669ffb89 100644 --- a/test/compiler/inference.jl +++ b/test/compiler/inference.jl @@ -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)