Skip to content

Convert character offset to byte offset in parse_inline_*_annotation#2945

Open
pjocprac wants to merge 1 commit intoruby:masterfrom
pjocprac:fix-parse-inline-annotation-byte-offset
Open

Convert character offset to byte offset in parse_inline_*_annotation#2945
pjocprac wants to merge 1 commit intoruby:masterfrom
pjocprac:fix-parse-inline-annotation-byte-offset

Conversation

@pjocprac
Copy link
Copy Markdown

@pjocprac pjocprac commented May 1, 2026

Summary

  • parse_inline_*_annotation were skipped during the byte-offset migration (Specify input range by byte offsets #2863), causing parse errors on multibyte content.
  • Apply the existing byte_range helper to convert offsets, matching the pattern used by parse_type etc.

See the commit message for details.

Refs

Test plan

  • Multibyte regression tests added
  • bundle exec rake test — 938 tests, 7643 assertions, 0 failures, 0 errors

@pjocprac pjocprac marked this pull request as ready for review May 1, 2026 03:45
Parser.parse_inline_leading_annotation and parse_inline_trailing_annotation
were passing character offsets directly to the C parser, which expects byte
offsets since ruby#2863. With ASCII-only input the two coincide so the bug was
hidden, but multibyte content (e.g. a Japanese comment preceding the
annotation) caused the C parser to start at an invalid byte position and
emit a parsing error.

Apply the existing byte_range helper to convert character offsets to byte
offsets, matching the pattern used by parse_type, parse_method_type, and
other parse_* methods.

The existing tests for parse_inline_*_annotation used ASCII-only input
which would not catch this class of bug, so multibyte regression tests are
added.
@pjocprac pjocprac force-pushed the fix-parse-inline-annotation-byte-offset branch from 5e378f2 to 84edc05 Compare May 1, 2026 03:54
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.

parse_inline_*_annotation fails on multibyte content (since #2863)

1 participant