Skip to content

Preserve complete UTF-8 characters in parse error snippets - #1090

Merged
byroot merged 1 commit into
ruby:masterfrom
ydah:fix-error-fragment-utf8
Oct 2, 2026
Merged

byroot merged 1 commit into
ruby:masterfrom
ydah:fix-error-fragment-utf8

Conversation

@ydah

@ydah ydah commented Oct 2, 2026

Copy link
Copy Markdown
Member

Error snippets always drop their final multibyte character, even when it is complete.

require "json"

JSON.parse('[1, é')
# Before: unexpected character: '' at line 1 column 5
# After: unexpected character: 'é' at line 1 column 5

Only trim an incomplete character when the 32-byte limit splits it. Add coverage for complete characters, whitespace boundaries, and truncated 2-, 3-, and 4-byte characters.

@byroot
byroot merged commit c484f8f into ruby:master Oct 2, 2026
42 checks passed
@byroot

byroot commented Oct 2, 2026

Copy link
Copy Markdown
Member

Thank you!

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.

2 participants