From acdf4459dea73eff40f7bdebfd033f6b4a189840 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Mon, 20 Jul 2026 20:05:39 +0200 Subject: [PATCH] make printing robust to if JuliaInterpreter quotes it or not --- src/printing.jl | 6 ++++-- test/misc.jl | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/printing.jl b/src/printing.jl index eed57a8..99f3d7f 100644 --- a/src/printing.jl +++ b/src/printing.jl @@ -226,12 +226,14 @@ end function expression_for_display(frame::Frame) expr = pc_expr(frame) - if expr isa GlobalRef && frame.pc < nstatements(frame.framecode) + if expr isa Union{GlobalRef, QuoteNode} && frame.pc < nstatements(frame.framecode) # Julia 1.12 may pause on a global lookup followed by separate argument # loads and then a call. Preview that call so the status still shows the # call rather than just `Main.:+` — both when the global is the callee # and when it is an argument (e.g. pausing on `Base.Math.:*` inside - # a call like `map(*, x, y)`). + # a call like `map(*, x, y)`). JuliaInterpreter's `optimize!` may fold + # a const `GlobalRef` statement into a `QuoteNode` of its value, so + # accept both forms. for next_pc in (frame.pc + 1):nstatements(frame.framecode) stmt = pc_expr(frame, next_pc) call = isexpr(stmt, :(=)) ? stmt.args[2] : stmt diff --git a/test/misc.jl b/test/misc.jl index c4d6b92..d791c0c 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -65,7 +65,9 @@ frame.pc = 1 f_preview_arg(x, y) = map(*, x, y) let frame = JuliaInterpreter.enter_call(f_preview_arg, [1, 2], [3, 4]) nst = JuliaInterpreter.nstatements(frame.framecode) - pcstar = findfirst(i -> (e = pc_expr(frame, i); e isa GlobalRef && e.name == :*), 1:nst) + # the load is a `GlobalRef`, or a `QuoteNode` when JuliaInterpreter folded the const + pcstar = findfirst(i -> (e = pc_expr(frame, i); + (e isa GlobalRef && e.name == :*) || (e isa QuoteNode && e.value === *)), 1:nst) # globals load as separate statements only in newer lowering (Julia 1.12+) if pcstar !== nothing while frame.pc < pcstar