From 74cead11629600a6f5aa3698a2f785be5cbecfc5 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> Date: Wed, 3 Jul 2024 02:23:59 +0900 Subject: [PATCH] inference: add missing `MustAlias` widening in `_getfield_tfunc` (#54996) 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 a030cebdeacca..8b778b86db8f0 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -1095,7 +1095,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 b661fcc384268..f203d411a4424 100644 --- a/test/compiler/inference.jl +++ b/test/compiler/inference.jl @@ -2569,6 +2569,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)