From e5e9e57091fbb3f74f8fb34253472c2ae40d04da Mon Sep 17 00:00:00 2001 From: maartenvd Date: Thu, 11 Jul 2024 15:43:29 +0200 Subject: [PATCH 1/2] Update reflection.jl --- src/reflection/reflection.jl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/reflection/reflection.jl b/src/reflection/reflection.jl index 2f715c5..31f4dec 100644 --- a/src/reflection/reflection.jl +++ b/src/reflection/reflection.jl @@ -89,7 +89,13 @@ function invoke_tweaks!(ci::CodeInfo) ci.slotflags = [0x00, ci.slotflags[1], 0x00, ci.slotflags[2:end]...] ci.code = map(ci.code) do x prewalk(x) do x - x isa SlotNumber ? SlotNumber(x.id == 1 ? 2 : x.id+2) : x + if x isa SlotNumber + SlotNumber(x.id == 1 ? 2 : x.id+2) + elseif x isa Core.ReturnNode && x.val isa SlotNumber + Core.ReturnNode(SlotNumber(x.val.id == 1 ? 2 : x.val.id+2)) + else + x + end end end end From d2305796a548c64ce3a46408d1fcfaf1ba564c9c Mon Sep 17 00:00:00 2001 From: maartenvd Date: Fri, 12 Jul 2024 12:40:40 +0200 Subject: [PATCH 2/2] Update src/reflection/reflection.jl Co-authored-by: Paul Berg --- src/reflection/reflection.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/reflection/reflection.jl b/src/reflection/reflection.jl index 31f4dec..5851bc2 100644 --- a/src/reflection/reflection.jl +++ b/src/reflection/reflection.jl @@ -91,7 +91,7 @@ function invoke_tweaks!(ci::CodeInfo) prewalk(x) do x if x isa SlotNumber SlotNumber(x.id == 1 ? 2 : x.id+2) - elseif x isa Core.ReturnNode && x.val isa SlotNumber + elseif x isa Core.ReturnNode && isdefined(x, :val) && x.val isa SlotNumber Core.ReturnNode(SlotNumber(x.val.id == 1 ? 2 : x.val.id+2)) else x