Skip to content

Proc/Method: genuine #call/#== aliases, Proc#==/#eql?, lambda-aware curry (MRI 4.0.6) - #548

Merged
tannevaled merged 2 commits into
mainfrom
feat/agent-procmeth
Sep 1, 2026
Merged

tannevaled merged 2 commits into
mainfrom
feat/agent-procmeth

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

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.go and a new test file.

What changed

Genuine built-in aliases (identity, not just same body). Proc#[], Proc#yield, Proc#=== now share the one #call *Method record, and Method#[] / Method#=== share Method#call — so instance_method(:[]) == instance_method(:call), as MRI models genuine aliases. Previously each was a separate define and compared unequal.

Proc#== / Proc#eql?. Defined on Proc as identity equality (#eql? the same record), so #== appears in Proc.public_instance_methods(false) and pairs with #eql?. A #dup returns 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? is true, proc{}.curry.lambda? is false). curry(n) on a lambda now raises ArgumentError when n is fewer than the required arity, or more than a splat-less lambda accepts; a non-lambda proc still curries to any width. Implemented via new curriedProc / procPositionalInfo helpers in proc.go (the arith.go curried helper is left untouched).

Spec deltas (rubyspec, MRI 4.0.6)

  • proc/curry 23→26, proc/lambda 8→10, proc/eql 0→1, proc/equal_value 9→10
  • proc/element_reference, proc/case_compare, proc/yield 0→1 each
  • method/element_reference, method/case_compare 0→1 each

Net +14 examples across the target suite, no regressions.

Out of scope / not attempted

  • source_location line numbers (report line 0): the VM tracks no per-instruction line info; fixing needs compiler/bytecode line tracking.
  • Proc#to_s file:line + binary encoding: the codebase deliberately keeps the stable pointerless #<Proc> form (many tests depend on it); binary-encoding needs String internals.
  • Proc.new subclass allocation, respond_to_missing?-generated methods, method(:+) operator resolution, and native-proc block forwarding (compose block-passing, Method#to_proc yield): each needs machinery outside these two files.

Verification (GOWORK=off CGO_ENABLED=0)

  • go test ./internal/vm/ green; go test ./... green
  • GOOS=wasip1 GOARCH=wasm go build ./... OK
  • gofmt -l clean on changed files
  • New/changed funcs curriedProc, procPositionalInfo, registerMethod, registerProcMethods at 100.0% coverage; all edited builtins.go blocks covered; repo total 99.9% (pre-existing knife-edge, not lowered).

🤖 Generated with Claude Code

tannevaled and others added 2 commits September 1, 2026 16:43
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>
@tannevaled
tannevaled merged commit f5dd19b into main Sep 1, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/agent-procmeth branch September 1, 2026 18:17
tannevaled added a commit that referenced this pull request Sep 3, 2026
Locks in #548 (Proc/Method/UnboundMethod), #549 (Integer/Float/Numeric) and
#550 (Enumerator/Lazy/Yielder). Measured 18245 passing on the pinned corpus,
up from 18102.

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