Skip to content

Leave a quoted callee that has no name alone in normalize_defsig - #176

Draft
nsiccha wants to merge 1 commit into
JuliaDebug:masterfrom
nsiccha:fix/quoted-callable-callee
Draft

nsiccha wants to merge 1 commit into
JuliaDebug:masterfrom
nsiccha:fix/quoted-callable-callee

Conversation

@nsiccha

@nsiccha nsiccha commented Nov 2, 2026

Copy link
Copy Markdown

My AI says I need this, but I haven't yet had time to review, uploaded this as an FYI only. Review at your own peril.

Upstream fix: Revise could not track a macro-generated method calling a quoted callable value (nameof MethodError in normalize_defsig). Reproducer, the change, tests on Julia 1.10.12 and 1.13.1. · Claude:remote-agents:snag.revise-signature-639b9c6d · claude-fable-5-1@xhigh

A macro may interpolate an arbitrary value as the callee of a call in a method body, e.g. apply_offset(x) = $(QuoteNode(Offset(2.0)))(x) where Offset is a callable struct. The call lowers to a :call whose callee is that QuoteNode, and normalize_defsig called nameof on its value. Only functions, types and modules have a nameof, so walking the body threw, and Revise could not track the file (Revise.SignatureExtractionError … caused by: MethodError: no method matching nameof(::Offset)) although include runs it fine. #149 fixed the same for a quoted Symbol; this is the remaining half.

Reproducer

using LoweredCodeUtils, JuliaInterpreter
struct Offset
    value::Float64
end
(offset::Offset)(x) = x + offset.value
ex = :(apply_offset(x) = $(QuoteNode(Offset(2.0)))(x))
methodinfos, selfcalls = LoweredCodeUtils.identify_framemethod_calls(Frame(Main, ex))

On LoweredCodeUtils 3.10.2 (master at 6f5c109), Julia 1.10.12, JuliaInterpreter 0.12.2:

ERROR: MethodError: no method matching nameof(::Offset)

With this change, methodinfos is Dict(GlobalRef(Main, :apply_offset) => MethodInfo(2, 7, [1])) and selfcalls is empty. Through Revise 3.18.0, includet of a file holding that definition tracks it, and later edits of the macro argument, of the callable's body, and added or deleted generated methods are applied.

Change

normalize_defsig calls nameof only when the quoted value is a Function, DataType, UnionAll or Module (the kinds Base.nameof is defined for; Core.IntrinsicFunction <: Function), which keeps the folded const callees JuliaInterpreter produces, and returns any other quoted value as it is: it is not a name, so it is never a self-call, and every caller already handles a result that is not a GlobalRef. A testset covers the callable-struct instance (plus an integer, a string and a Union type), the function, type and module cases that still normalize, and walking and defining apply_offset end to end.

Tests pass on Julia 1.10.12 (185/185) and Julia 1.13.1 (205/205).

🤖 Generated with Claude Code

https://claude.ai/code/session_01GvfBWGxnUzWjHVUwWFLjCc

A macro may interpolate an arbitrary value as the callee of a call in a
method body, e.g. `$(QuoteNode(Offset(2.0)))(x)` where `Offset` is a
callable struct. The call lowers to a `:call` whose callee is that
`QuoteNode`, and `normalize_defsig` called `nameof` on its value. Only
functions, types and modules have a `nameof`, so walking the body threw
`MethodError: no method matching nameof(::Offset)` and Revise could not
track the file (`Revise.SignatureExtractionError`), although `include`
runs it fine.

Call `nameof` only for a quoted function, type or module (the folded
`const` callees JuliaInterpreter produces) and return any other quoted
value as it is: it is not a name, so it is never a self-call.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GvfBWGxnUzWjHVUwWFLjCc

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant