From 96c4b2a039014575721be55b049687c1710485ae Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Wed, 16 Sep 2026 20:09:42 +0400 Subject: [PATCH] Give get_effects(::MultiCallInfo) an identity for empty callinfos `mapreduce(get_effects, merge_effects, callinfos)` has no `init`, so an empty `MultiCallInfo` threw instead of yielding effects. `select_callsite` already guards the empty case, but any effects display reaches `get_effects` first. `EFFECTS_TOTAL` is the identity of `merge_effects`. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01NiXhCrQf5AJ2DmTmZ3FsSP --- src/compiler/callsite.jl | 2 +- test/test_Cthulhu.jl | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/callsite.jl b/src/compiler/callsite.jl index 328042a5..eeb78aa9 100644 --- a/src/compiler/callsite.jl +++ b/src/compiler/callsite.jl @@ -96,7 +96,7 @@ struct MultiCallInfo <: CallInfo end get_ci(ci::MultiCallInfo) = error("Can't extract MethodInstance from multiple call informations") get_rt(ci::MultiCallInfo) = ci.rt -get_effects(mci::MultiCallInfo) = mapreduce(get_effects, CC.merge_effects, mci.callinfos) +get_effects(mci::MultiCallInfo) = mapreduce(get_effects, CC.merge_effects, mci.callinfos; init=EFFECTS_TOTAL) get_exct(ci::MultiCallInfo) = ci.exct struct TaskCallInfo <: CallInfo diff --git a/test/test_Cthulhu.jl b/test/test_Cthulhu.jl index b6a171f0..d2054f03 100644 --- a/test/test_Cthulhu.jl +++ b/test/test_Cthulhu.jl @@ -401,6 +401,9 @@ end @test occursin("< opaque closure call > $s", String(take!(buf))) end +# an empty MultiCallInfo has no effects to merge; `mapreduce` without `init` threw +@test Cthulhu.get_effects(Cthulhu.MultiCallInfo(Tuple{}, Any, Cthulhu.CallInfo[])) == Cthulhu.CC.EFFECTS_TOTAL + # tasks ftask() = @sync @async show(io, "Hello") let callsites = find_callsites_by_ftt(ftask, Tuple{})