Repository navigation
Proc/Method: genuine #call/#== aliases, Proc#==/#eql?, lambda-aware curry (MRI 4.0.6) - #548
Merged
Merged
Conversation
Advance MRI 4.0.6 conformance for the Proc/Method cluster: - Proc#[], #yield, #=== and Method#[], #=== are now genuine built-in aliases of #call (one shared *Method record), so #instance_method(:[]) equals #instance_method(:call). Fixes core/proc element_reference/yield/case_compare and core/method element_reference/case_compare. - Proc#== is defined on Proc as identity equality, with #eql? as the same definition, so #== appears in Proc.public_instance_methods(false) and pairs with #eql?. Fixes core/proc/eql and equal_value. - Proc#curry keeps the receiver's lambda-ness (propagated through every partial application) and, for a lambda, raises ArgumentError when curried to an arity the lambda cannot satisfy. Fixes core/proc curry and lambda?. curriedProc/procPositionalInfo added in proc.go (the arith.go curried helper is left untouched). No regressions: go test ./internal/vm/ green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add internal/vm/proc_method_residuals_test.go (package vm_test) covering the new behaviour: #[]/#yield/#=== and Method#[]/#=== alias identity with #call, Proc#==/#eql? identity semantics and public visibility, curry lambda-ness retention through partial application, curried-arg gathering, and the lambda-only curry(n) arity ArgumentError (with the non-raising proc/splat/ optional cases). Drives curriedProc and procPositionalInfo to 100%. 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.
Advance MRI 4.0.6 conformance for the Proc / Method / UnboundMethod cluster. All changes are confined to
internal/vm/proc.go,internal/vm/method.go,internal/vm/builtins.goand a new test file.What changed
Genuine built-in aliases (identity, not just same body).
Proc#[],Proc#yield,Proc#===now share the one#call*Methodrecord, andMethod#[]/Method#===shareMethod#call— soinstance_method(:[]) == instance_method(:call), as MRI models genuine aliases. Previously each was a separatedefineand compared unequal.Proc#==/Proc#eql?. Defined onProcas identity equality (#eql?the same record), so#==appears inProc.public_instance_methods(false)and pairs with#eql?. A#dupreturns the same object, so a proc equals its dup; distinct procs (and non-procs) are unequal.Lambda-aware
Proc#curry. The curried proc keeps the receiver's lambda-ness and propagates it through every partial application (->{}.curry.lambda?istrue,proc{}.curry.lambda?isfalse).curry(n)on a lambda now raisesArgumentErrorwhennis fewer than the required arity, or more than a splat-less lambda accepts; a non-lambda proc still curries to any width. Implemented via newcurriedProc/procPositionalInfohelpers inproc.go(thearith.gocurriedhelper is left untouched).Spec deltas (rubyspec, MRI 4.0.6)
Net +14 examples across the target suite, no regressions.
Out of scope / not attempted
source_locationline numbers (report line 0): the VM tracks no per-instruction line info; fixing needs compiler/bytecode line tracking.Proc#to_sfile:line + binary encoding: the codebase deliberately keeps the stable pointerless#<Proc>form (many tests depend on it); binary-encoding needs String internals.Proc.newsubclass allocation,respond_to_missing?-generated methods,method(:+)operator resolution, and native-proc block forwarding (compose block-passing,Method#to_procyield): each needs machinery outside these two files.Verification (GOWORK=off CGO_ENABLED=0)
go test ./internal/vm/green;go test ./...greenGOOS=wasip1 GOARCH=wasm go build ./...OKgofmt -lclean on changed filescurriedProc,procPositionalInfo,registerMethod,registerProcMethodsat 100.0% coverage; all editedbuiltins.goblocks covered; repo total 99.9% (pre-existing knife-edge, not lowered).🤖 Generated with Claude Code