Repository navigation
Advance Marshal conformance: Data dump/load and Regexp encoding - #524
Merged
Merged
Conversation
Data.define instances (Ruby 3.2+ immutable value objects) store their members in RObject.structVals the same way a Struct does, and MRI marshals them with the same 'S' container. Emit that on dump and accept it on load via memberDefNames, reconstructing a frozen Data instance. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
MRI records a Regexp's encoding the same way it records a String's: bare (no encoding ivar) for a binary source, an :E => true/false marker for UTF-8/US-ASCII, and a named :encoding ivar otherwise. The option byte carries the FIXEDENCODING (0x10) and NOENCODING (0x20) bits, and an ASCII-incompatible source (UTF-16/UTF-32) is fixed even when its bytes are ASCII-only. Compute the encoding from the compiled Regexp (via encodingName plus the fixed source encoding), pick the option byte to match, and restore both on load so a Regexp round-trips byte-for-byte. A non-ASCII source stays content-fixed (its fixedEnc field left false) so a loaded /café/ still equals the literal. Fixes the four encoding examples in core/marshal/dump_spec (binary, ascii-compatible, UTF-8, another-encoding); the remaining Regexp residuals need the object model to carry a Regexp subclass identity and ivars. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
tannevaled
added a commit
that referenced
this pull request
Aug 31, 2026
* Raise ruby/spec floor to 17470 after wave-3 conformance work Locks in the gains from #521 (regexp \xHH), #523 (String#encode fallback/xml/IBM437/default_internal), #524 (Marshal Data + Regexp encoding), #525 (Module#define_method arity/visibility/hooks) and #522 (sprintf %c/named-default/hex-float). Measured 17470 passing on the pinned corpus, up from 17310. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * ci: re-trigger after transient GOPROXY stream errors Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- 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.
Marshal MRI-4.0.6 conformance: Data + Regexp encoding
Advances
core/marshal/dump_spec.rbandcore/marshal/load_spec.rbagainst MRI 4.0.6. Two self-contained clusters, entirely withininternal/vm/marshal_codec.goplus a new test file.Data (
Data.define, Ruby 3.2+ immutable value objects)Sstruct container (member name/value pairs), the same encoding MRI uses, using the real class name (never a#nameoverride).memberDefNames, reconstructing a frozen instance (Data is immutable regardless of thefreeze:kwarg).Regexp encoding + option byte
:E => true/falsefor UTF-8/US-ASCII, a named:encodingivar otherwise.FIXEDENCODING(0x10) andNOENCODING(0x20) bits; treat an ASCII-incompatible source (UTF-16/UTF-32) as fixed even when its bytes are ASCII-only./café/equal to the literal.Conformance deltas
dump_spec: 162 → 170 pass (+8)load_spec: 210 → 213 pass (+3)Out of scope (object-model / lexer / non-marshal, per task boundaries)
extend/subclass identity — core value types don't carry ivars or a class override.UserRegexp.newyields a plainRegexp.Symbol#encoding).time.go), Exception message re-encoding (in the constructor).Array#==uses identity/eql?for custom-==elements (core comparison, not marshal) — this alone accounts for the three "…and with proc" / "loads a user-marshaled object" load failures, whose loaded objects are structurally correct._dump_data/_load_data) andRandom— need builtins.Verification
go test ./internal/vm/andgo test ./...green.GOOS=js GOARCH=wasm) OK.gofmt -lempty on changed files.-coverpkgover./internal/...).🤖 Generated with Claude Code