Repository navigation
Method / UnboundMethod: advance MRI 4.0.6 conformance (super_method, inspect, dup/clone) - #566
Merged
Merged
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advances
core/method/*andcore/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_methodfollows 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'ssuperwould — instead of raisingundefined method 'owner' for nilwhen the alias name has no ancestor.UnboundMethodnow records the class it was extracted from (origin) and walks that class's full ancestor list, so asuperthat crosses between two modules mixed into one class is found (the JRuby #7240 scenario).core/method/super_method5 → 6,core/unboundmethod/super_method4 → 6.#inspect/#to_sreceiver-and-owner heads (fixes 7)Method#inspectandUnboundMethod#inspectnow render the head as MRI does: a class method readsRecv.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 anUnboundMethod's head is the defining module/singleton class inspected.core/method/to_s10 → 15,core/method/unbind6 → 7.Instance variables, freeze, and dup/clone (fixes 8)
BoundMethodandUnboundMethodnow carry an embeddedmethodValueState(instance variables with insertion order + a frozen flag), reached through aboxedinterface by the shared ivar/freeze/copy helpers exactly asRObjectexposes 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_locationline numbers — needs compiler per-node line tracking.obj.method(:+)(call,parameters, oneto_proc) — arithmetic operators are compiler fast-paths, not editable numeric method-table entries.Method#to_procbinding/block forwarding — native procs carry no binding and cannot forward a block through their signature.#ownerreporting the class wherepublic/privatewas called,UnboundMethod#bindacross metaclass hierarchies, and theequal_valueClass.newmetaclass-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 tosuper_method, and changing it would regress thesuper_methodfix.arity_spec— uses the unimplemented mspecSpecEvaluateDSL (harness gap).to_scase needs object0x…addresses in default inspect.Verification
go test ./internal/vm/green;go test ./...green;GOOS=js GOARCH=wasmbuild OK;gofmt -lclean.internal/vm/method_residuals_wave12_test.go; every changed named function 100% exceptivarTable, whose only uncovered block is the pre-existing, unmodifiedActionViewBaselazy-init (not part of this diff).🤖 Generated with Claude Code