Skip to content

Method / UnboundMethod: advance MRI 4.0.6 conformance (super_method, inspect, dup/clone) - #566

Merged
tannevaled merged 3 commits into
mainfrom
feat/agent-method2
Sep 5, 2026
Merged

tannevaled merged 3 commits into
mainfrom
feat/agent-method2

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Advances core/method/* and core/unboundmethod/* conformance against MRI 4.0.6. Net: +17 passing examples across the two clusters (pass 213 → 230), fail 31 → 17, error 19 → 16, with no regressions.

Changes

#super_method follows the original definition (fixes 3 crashes)

The super search now walks a method's original name, so an alias (alias_method :meow, :derp) or a visibility-changed inherited method reaches the same ancestor MRI's super would — instead of raising undefined method 'owner' for nil when the alias name has no ancestor. UnboundMethod now records the class it was extracted from (origin) and walks that class's full ancestor list, so a super that crosses between two modules mixed into one class is found (the JRuby #7240 scenario).

  • core/method/super_method 5 → 6, core/unboundmethod/super_method 4 → 6.

#inspect / #to_s receiver-and-owner heads (fixes 7)

Method#inspect and UnboundMethod#inspect now render the head as MRI does: a class method reads Recv.name / Child(Parent).name; a module method reaching a class object shows through its metaclass as #<Class:Recv>(Owner)#name; an anonymous-class instance uses the # separator; and an UnboundMethod's head is the defining module/singleton class inspected.

  • core/method/to_s 10 → 15, core/method/unbind 6 → 7.

Instance variables, freeze, and dup/clone (fixes 8)

BoundMethod and UnboundMethod now carry an embedded methodValueState (instance variables with insertion order + a frozen flag), reached through a boxed interface by the shared ivar/freeze/copy helpers exactly as RObject exposes its own ivars. #instance_variable_set/get/#instance_variables, #freeze/#frozen?, #dup (copies ivars, resets frozen) and #clone (copies ivars, preserves frozen) now match MRI 3.4+.

  • core/method/{clone,dup} 1 → 3 each, core/unboundmethod/{clone,dup} 1 → 3 each.

Out of scope (reported, not fixed)

  • #source_location line numbers — needs compiler per-node line tracking.
  • Operator methods via obj.method(:+) (call, parameters, one to_proc) — arithmetic operators are compiler fast-paths, not editable numeric method-table entries.
  • Method#to_proc binding/block forwarding — native procs carry no binding and cannot forward a block through their signature.
  • #owner reporting the class where public/private was called, UnboundMethod#bind across metaclass hierarchies, and the equal_value Class.new metaclass-alias cases — all require MRI's two-level method-entry model (a refined/zsuper entry with a metaclass owner); our single-owner model couples owner to super_method, and changing it would regress the super_method fix.
  • arity_spec — uses the unimplemented mspec SpecEvaluate DSL (harness gap).
  • One to_s case needs object 0x… addresses in default inspect.

Verification

  • go test ./internal/vm/ green; go test ./... green; GOOS=js GOARCH=wasm build OK; gofmt -l clean.
  • New branches covered by internal/vm/method_residuals_wave12_test.go; every changed named function 100% except ivarTable, whose only uncovered block is the pre-existing, unmodified ActionViewBase lazy-init (not part of this diff).

🤖 Generated with Claude Code

tannevaled and others added 3 commits September 5, 2026 21:22
… heads

super_method now follows a method's ORIGINAL name, so an alias
(alias_method :meow, :derp) or a visibility-changed inherited method
reaches the same super MRI's `super` would — fixing the "undefined method
'owner' for nil" crashes when the alias name has no ancestor. UnboundMethod
now records the class it was extracted from (origin) and walks that class's
full ancestor list, so a `super` that crosses between two modules mixed into
one class is found.

Method#inspect / UnboundMethod#inspect now render the receiver/owner head as
MRI does: a class method reads Recv.name / Child(Parent).name; a module
method reaching a class object shows through its metaclass as
#<Class:Recv>(Owner)#name; an anonymous class instance uses the # separator;
and an UnboundMethod's head is the defining module/singleton class inspected.

core/method: super_method 5->6, to_s 10->15, unbind 6->7.
core/unboundmethod: super_method 4->6.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
BoundMethod and UnboundMethod now carry an embedded methodValueState holding
instance variables (with insertion order) and a frozen flag, reached through
the boxed interface by the shared ivar/freeze/copy helpers exactly as RObject
exposes its own ivars. #instance_variable_set/get/#instance_variables work,
#freeze/#frozen? work, #dup copies ivars and resets frozen, and #clone copies
ivars and preserves frozen — matching MRI 3.4+.

core/method: clone 1->3, dup 1->3.
core/unboundmethod: clone 1->3, dup 1->3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds Go tests exercising Method#super_method returning nil at the top of a
chain and the freeze/frozen? default fall-through for a non-boxed value, so
every added branch is covered.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit e5fb500 into main Sep 5, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/agent-method2 branch September 5, 2026 20:45
tannevaled added a commit that referenced this pull request Sep 5, 2026
Locks in #565 (MatchData / regexp-engine \u escapes + duplicate/non-ASCII
capture names), #566 (Method/UnboundMethod) and #567 (Array + pack). Measured
18767 passing on the pinned corpus, up from 18650.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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