From b6922e24db0813b1ddf122b21b667f7dc35b7e92 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Sat, 27 Jan 2024 14:55:48 +0900 Subject: [PATCH] forward-port the test cases added in #53076 The fix for #53062 was included in #50805, but it lacked explicit test cases added. This commit cherry-picks the test cases from #53076 to prevent future regression. --- base/compiler/ssair/inlining.jl | 2 +- test/compiler/inline.jl | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/base/compiler/ssair/inlining.jl b/base/compiler/ssair/inlining.jl index bacaf68db4332..48e9dd431747c 100644 --- a/base/compiler/ssair/inlining.jl +++ b/base/compiler/ssair/inlining.jl @@ -1396,7 +1396,7 @@ function compute_inlining_cases(@nospecialize(info::CallInfo), flag::UInt32, sig fully_covered &= split_fully_covered end - (handled_all_cases && fully_covered) || (joint_effects = Effects(joint_effects; nothrow=false)) + (handled_all_cases & fully_covered) || (joint_effects = Effects(joint_effects; nothrow=false)) if handled_all_cases && revisit_idx !== nothing # we handled everything except one match with unmatched sparams, diff --git a/test/compiler/inline.jl b/test/compiler/inline.jl index 9e58f23fd755c..0ef7f6def1057 100644 --- a/test/compiler/inline.jl +++ b/test/compiler/inline.jl @@ -2116,3 +2116,20 @@ let src = code_typed1() do end @test count(isinvoke(:iterate), src.code) == 0 end + +# JuliaLang/julia#53062: proper `joint_effects` for call with empty method matches +let ir = first(only(Base.code_ircode(setproperty!, (Base.RefValue{Int},Symbol,Base.RefValue{Int})))) + i = findfirst(iscall((ir, convert)), ir.stmts.stmt)::Int + @test iszero(ir.stmts.flag[i] & Core.Compiler.IR_FLAG_NOTHROW) +end +function issue53062(cond) + x = Ref{Int}(0) + if cond + x[] = x + else + return -1 + end +end +@test !Core.Compiler.is_nothrow(Base.infer_effects(issue53062, (Bool,))) +@test issue53062(false) == -1 +@test_throws MethodError issue53062(true)