Repository navigation
String#encode: fallback #to_str/validation, xml NCRs, IBM437, default_internal, converter-not-found - #523
Merged
Conversation
…frozen Advance core/string/encode_spec.rb from 106 to 134 passing examples: - :fallback now converts a non-String result via #to_str (never #to_s), rejects a substitute unrepresentable in the target with ArgumentError "too big fallback string", and treats an object without #[] as no fallback (the char falls through to the normal UndefinedConversionError). - xml: :text / :attr render a character absent from the destination as an upper-case numeric character reference (&#xHH;) instead of raising. - IBM437 gains a codec (charmap.CodePage437). - String#encode! raises FrozenError on a frozen receiver, even for a no-op. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…hortcut Continue advancing core/string/encode_spec.rb (134 -> 146 passing): - #encode with no destination transcodes to Encoding.default_internal when set. - An unusable destination (an unregistered name, or a dummy encoding like Emacs-Mule) is reported as Encoding::ConverterNotFoundError rather than an unknown-encoding ArgumentError or a premature UndefinedConversionError; a 7-bit ASCII String still transcodes to any ASCII-compatible destination as a byte-identical copy, matching MRI. - Encoding-name arguments resolve through the registry but pass an unknown name through verbatim so the missing-converter path reports it. - Adds internal/vm/encode_residuals_test.go and updates two stale expectations in encoding_encode_test.go to MRI's actual behaviour. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…er residuals The early converter check in stringEncode guarantees a supported destination before decode/encode/fallback run, and caseMapBytes decodes first, so the downstream unsupported-target branches in charEncodableIn, encodeFromUTF8 and xtextEncode became unreachable dead code. Remove them (xtextEncode no longer returns a found bool) and extend encode_residuals_test.go with the TypeError path for a non-convertible encoding argument. Merged coverage back to 100.0%. 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.
Advances
core/string/encode_spec.rbconformance against MRI Ruby 4.0.6, from 106 to 146 passing examples (was 28 fail / 18 error, now 4 fail / 2 error).Changes (all in
internal/vm/string_encode.go+string_encode_xtext.go)#to_str(never#to_s); a substitute that is itself unrepresentable in the target raisesArgumentError, "too big fallback string"; and a fallback object with no#[]is treated as no fallback, so the character falls through to the normalEncoding::UndefinedConversionError.ü) instead of raising.charmap.CodePage437).#encodewith no destination transcodes todefault_internalwhen one is set.Encoding::ConverterNotFoundErrorrather than an unknown-encodingArgumentErroror a prematureUndefinedConversionError. A 7-bit ASCII String still transcodes to any ASCII-compatible destination as a byte-identical copy, matching MRI.FrozenErroron a frozen receiver, even for a no-op transcoding.charEncodableIn/encodeFromUTF8/xtextEncode, and updated two stale expectations inencoding_encode_test.goto MRI's actual behaviour.Remaining (out of scope for these files)
6 example-instances still fail: two need an Emacs-Mule codec (absent from golang.org/x/text), and the rest hinge on
Encoding::Converter.new(Emacs_Mule, BINARY)raisingConverterNotFoundError(lives inconverter_impl.go).Verification
core/string/encode_spec.rb: 106 → 146 passing, no regressions (spot-checkedupcase_spec).go test ./internal/vm/green;go test ./...green;GOOS=wasip1 GOARCH=wasm go build ./...OK;gofmt -lclean on changed files.-coverpkgover allinternal/...): 100.0%.🤖 Generated with Claude Code