Convert character offset to byte offset in parse_inline_*_annotation#2945
Open
pjocprac wants to merge 1 commit intoruby:masterfrom
Open
Convert character offset to byte offset in parse_inline_*_annotation#2945pjocprac wants to merge 1 commit intoruby:masterfrom
pjocprac wants to merge 1 commit intoruby:masterfrom
Conversation
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.
5e378f2 to
84edc05
Compare
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.
Summary
parse_inline_*_annotationwere skipped during the byte-offset migration (Specify input range by byte offsets #2863), causing parse errors on multibyte content.byte_rangehelper to convert offsets, matching the pattern used byparse_typeetc.See the commit message for details.
Refs
Test plan
bundle exec rake test— 938 tests, 7643 assertions, 0 failures, 0 errors