Skip to content

String: advance MRI 4.0.6 conformance (non-encoding method residuals) - #562

Merged
tannevaled merged 4 commits into
mainfrom
feat/agent-strmeth2
Sep 4, 2026
Merged

tannevaled merged 4 commits into
mainfrom
feat/agent-strmeth2

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Advances MRI 4.0.6 conformance for non-encoding String method behaviour (encoding negotiation is owned separately). Measured against core/string/*_spec.rb.

Changes

  • Built-in aliases — next/next!/intern/to_str now share the exact Method record of succ/succ!/to_sym/to_s (via aliasBuiltin), so instance_method(:next) == instance_method(:succ) etc.
  • String#<=> — accepts a String subclass by value, converts a #to_str operand (rb_check_string_type), and inverts other <=> self (rb_invcmp) with a recursion guard for the mutually-inverting operand case.
  • String#== — dedicated method with rb_str_equal semantics (subclass by value; defers to other == self when the operand answers #to_str); the ==/!= operator fast path defers likewise.
  • String#to_f — allows a single inter-digit underscore in the integer/fraction/exponent runs; treats NUL and other non-printable bytes as terminals rather than leading whitespace.
  • String#to_i — base 0 with a leading 0 selects octal; the base argument is coerced via #to_int.
  • String#getbyte — raises ArgumentError unless given exactly one argument.
  • String#upto — iterates a single-ASCII-character run by codepoint ("9".upto("A")); coerces the end argument via #to_str; the no-block Enumerator reports nil size.
  • String#start_with? — coerces a non-Regexp prefix via #to_str (keeping the encoding-compatibility check) and sets/clears $~ for a Regexp argument.

Spec deltas (core/string, non-encoding)

spec before after
comparison 15 19
equal_value 6 8
next 0 2
intern 0 1
to_str 0 1
to_f 17 20
to_i 55 57
getbyte 10 11
upto 13 16
start_with 9 11

Net +21 passing examples; remaining residuals in these files are encoding-negotiation cases (out of scope).

Verification

  • go test ./internal/vm/ and go test ./... green; GOOS=wasip1 GOARCH=wasm build OK; gofmt -l clean.
  • New internal/vm/string_method_wave11_test.go covers every new branch; each changed standalone function (binaryOp, stringOrSubclassBytes, spaceshipInvert, stringToInt, parseLeadingFloat, stringUpto) is 100% in the merged -coverpkg profile. No shadowed dead code.

🤖 Generated with Claude Code

tannevaled and others added 4 commits September 4, 2026 23:03
…limit)

Committed to protect against scratchpad purge; to be finished, verified and
squashed before the PR is opened.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…$~; tests

- getbyte: raise ArgumentError unless given exactly one argument.
- upto: iterate a single-ASCII-char run by codepoint ("9".upto("A")); coerce
  the end argument via #to_str; the no-block Enumerator reports nil size.
- start_with?: coerce a non-Regexp prefix via #to_str (keeping the encoding
  compatibility check), and set/clear $~ for a Regexp argument.
- Add internal/vm/string_method_wave11_test.go covering every new branch.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 191d44a into main Sep 4, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/agent-strmeth2 branch September 4, 2026 22:39
tannevaled added a commit that referenced this pull request Sep 5, 2026
Locks in #561 (StringIO / buffer IO), #562 (String non-encoding methods) and
#563 (Time). Measured 18650 passing on the pinned corpus, up from 18582.

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