Repository navigation
rubyspec shim: a nested describe can see the helpers of the one around it (+28) - #624
Merged
Merged
Conversation
…d it The shim runs each describe block with instance_eval, so a helper written with `def` inside the block lands on THAT context object's singleton. A nested describe runs on a different object and could not see it. core/string/valid_encoding/utf_8_spec.rb paid the whole bill: its examples call an outer `def utf8`, so all 28 raised NoMethodError. The file scored 0/28 under MRI 4.0.5 as well, run through the same shim — this was our harness, not a VM gap. With the fix both engines score 28/28. Each existing helper is forwarded explicitly to the enclosing context rather than routed through a method_missing. That distinction is not cosmetic: a method_missing on SpecContext puts a shim frame in the backtrace of a genuinely missing method, and language/send_spec asserts by name that method_missing does NOT appear there. The first attempt did exactly that and cost send_spec two examples and core/random/bytes_spec one; forwarding only methods that exist leaves a missing method raising from the caller, untouched. Measured over the whole pinned corpus with ONE binary built from main, so only the shim differs: 20905 -> 20936 passing. 28 of the 31 are utf_8_spec; the other 3 are core/module/autoload_spec, the file that crashes intermittently (#615), so they are noise rather than a second win. Refs #621. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
tannevaled
added a commit
that referenced
this pull request
Sep 23, 2026
Seven units since the last bump: #617 core/process: spawn, exec, the rlimits, priorities, process groups, kill, the wait family (pass 20 -> 165) #618 core/kernel + core/string: require_relative with an absolute path, the require/load argument contract, LoadError#path, byteindex/ byterindex, split, chop/chars/each_char (kernel 233 -> 184, string 179 -> 153 failing) #620 language: compound assignment evaluation order, the flip-flop operator, magic-comment encodings, loop break values (pass 1308 -> 1443) #622 object: Float#to_s laid out by MRI's rule rather than Go's %g (+11) #624 the mspec shim: a nested describe can see the helpers of the one around it (+28) #625 deps: parser v0.2.0 (language +333) #626 compiler: for-loop targets, block-local variables, what defined? declares (language +382) Measured with scripts/conformance/rubyspec/run.sh against the pinned corpus at 87b1631, 16-way, TIMEOUT=25, three consecutive runs: 21749, 21750, 21750. The floor is set nine below the lowest, the same margin rule as the last bump: it absorbs the run-to-run jitter without being wide enough to hide the loss of a whole spec file, which is what the ratchet exists to catch. #615 (an intermittent frame-pop crash) is still open and can cost a file when it fires. TWO OF THESE ARE NOT VM CONFORMANCE, and the number should not be read as if they were. #624 fixed our own mspec shim: core/string/valid_encoding/utf_8_spec scored 0/28 under MRI 4.0.5 too, so those 28 were harness noise counted as VM failure. #625 is a dependency bump; the VM did not change, but thirteen language spec files became parseable for the first time and brought 333 already- passing examples into view. Both are real gains in what the measurement can see, not in what the VM can do. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This was referenced Sep 23, 2026
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.
Refs #621.
The shim runs each
describeblock withinstance_eval, so a helper written withdefinside the block lands on that context object's singleton. A nesteddescriberuns on a different object and could not see it.It was the harness, not the VM
core/string/valid_encoding/utf_8_spec.rbpaid the whole bill — its examples call an outerdef utf8, so all 28 raisedNoMethodError. The proof it was ours: the file scored 0/28 under MRI 4.0.5 too, run through the same shim. With this change both engines score 28/28.Why explicit forwarding and not
method_missingThe first attempt added a
method_missingtoSpecContextthat forwarded to the parent. It fixed utf_8_spec and broke two other files:language/send_specasserts by name thatmethod_missingdoes not appear in the backtrace of a genuinely missing method:A
method_missingon the context object puts a shim frame in exactly the backtrace that spec is inspecting. Forwarding only the helpers that already exist leaves a missing method raising from the caller, untouched — and both files return to their previous counts.Measurement
One binary, built from
main, used for both runs, so the shim is the only difference. Whole pinned corpus, per file:Per-file, exactly two files move and both upward:
28 of the 31 are attributable; the other 3 are
autoload_spec, the file that crashes intermittently (#615), so they are run-to-run noise rather than a second win.Note for whoever bumps FLOOR next
This raises the ruby/spec total without improving the VM — it removes harness noise that was being counted as VM failure. A floor bump that includes it should say so, or the number will later be read as conformance work.
🤖 Generated with Claude Code