Repository navigation
Advance Marshal MRI conformance: symbols, Bignum links, exceptions, depth limit - #516
Merged
Merged
Conversation
…epth limit Extend the VM's byte-exact Marshal codec (internal/vm/marshal.go and marshal_codec.go) to match MRI 4.0.x on more of the format. Dump: - encode a non-ASCII Symbol as an 'I'-wrapped symbol with the :E=>true encoding ivar (rbgo's UTF-8 default), sharing the E symbol across the stream; pure-ASCII symbols stay bare. This also wraps non-ASCII ivar-name symbols, matching MRI. - link a repeated Bignum object like any other composite (a Fixnum-range Integer stays immediate and is never linked). - carry a compare_by_identity Hash in a 'C':Hash container. - emit an Exception via the :mesg / :bt pseudo-ivars (from @message and @__backtrace__), then the remaining ivars. - raise on a singleton object (per-object methods or singleton-class ivars), on an instance of an anonymous class through every hook, and word the anonymous-module message as "module". - enforce Marshal.dump's recursion limit, and raise "instance of IO needed" for a non-writable, non-Integer second argument; call #binmode on the IO when defined. Load: - trim the legacy NUL + mantissa suffix from a Float string before parsing. - restore compare_by_identity from a 'C':Hash container. - accept the legacy 'M' class-or-module reference; validate that 'c' names a class and 'm' a module. - read past an 'I'-wrapped encoded symbol. - map an Exception's :mesg / :bt onto @message / @__backtrace__. - use the load proc's return value in place of the loaded object. - raise EOFError for an empty IO source. Two existing marshal_test.go expectations encoded pre-MRI behaviour (a non-writable dump target was silently ignored; a load proc's return was discarded) and are corrected against the reference interpreter. rubyspec: core/marshal/dump_spec 145 -> 162 pass, load_spec 194 -> 210 pass. 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.
Extend the VM's byte-exact Marshal codec to match MRI 4.0.x on more of the format. Every expected value was checked byte-for-byte against the reference `ruby` interpreter.
rubyspec deltas
Total: +33 examples. No regressions across the broader core/marshal sweep.
internal/vm/marshal_codec.go
internal/vm/marshal.go
Tests
Verification
Out of scope (blocked by object model / other files)
🤖 Generated with Claude Code