Skip to content

Fix getSignatureAsArrayFor for Julia 1.12 (code_lowered ordering)#72

Merged
JKRT merged 1 commit into
OpenModelica:masterfrom
SVAGEN26:fix/getsignature-julia-1.12
Jun 17, 2026
Merged

Fix getSignatureAsArrayFor for Julia 1.12 (code_lowered ordering)#72
JKRT merged 1 commit into
OpenModelica:masterfrom
SVAGEN26:fix/getsignature-julia-1.12

Conversation

@SVAGEN26

Copy link
Copy Markdown
Contributor

This is SVAGEN26 (JKRT_CLAUDE), the Claude Code agent account acting on behalf of @JKRT.

Problem

On Julia 1.12, getSignatureAsArrayFor throws FieldError: type Core.SlotNumber has no field args. It fires on any @ExtendedFunction / @ExtendedAnonFunction expansion (verified via test/functionExtensionTest.jl).

Root cause

The function read default-argument values out of lowered IR via code_lowered(func)[1].code[1].args[2:end], assuming [1] is the lowest-arity auto-generated forwarding method (f(a) = f(a, defaults...)). On Julia 1.12 code_lowered returns highest-arity first, so [1] is now the full method whose body is Core.tuple(_2, _3, ...) (all SlotNumbers). .code[1] came back a bare Core.SlotNumber and .args threw.

Fix

Select carrier methods by arity rather than list position:

  • max-arity method -> argument names
  • min-arity forwarding call -> default values (SlotNumber/Argument = no default, literal = default; a single method = no defaults)

Resilient to future code_lowered reorderings. Also replaced abstract ::Integer/::Array locals with ::Int/::Vector, and bumped the version to 0.3.1.

Verification

test/functionExtensionTest.jl passes on Julia 1.12.6 (zero-arg, typed-default, anonymous, and nested-inheritance cases covered).

🤖 Generated with Claude Code

On Julia 1.12 code_lowered returns highest-arity first, so [1] was the
full method (body is all SlotNumbers) rather than the lowest-arity
default-forwarding method. Reading .code[1].args then threw
FieldError: Core.SlotNumber has no field args.

Select carrier methods by arity instead of list position: max-arity
method for argument names, min-arity forwarding call for default
values (SlotNumber/Argument means no default, literal means default;
a single method means no defaults). Resilient to future code_lowered
reorderings. Also replace abstract ::Integer/::Array locals with
::Int/::Vector. Bump to 0.3.1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JKRT JKRT self-requested a review June 17, 2026 17:40
@JKRT JKRT merged commit a132676 into OpenModelica:master Jun 17, 2026
3 checks passed
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.

2 participants