Repository navigation
Fix token 'end' offset for quoted identifiers, raw strings, and literals - #393
Open
ApparentlyTejas wants to merge 1 commit into
Open
ApparentlyTejas wants to merge 1 commit into
ApparentlyTejas wants to merge 1 commit into
Conversation
_consume_literal, _consume_quoted_identifier, and _consume_raw_string_literal all set the token's 'end' to the token's length instead of start + length, so 'end' was wrong (and less than 'start') whenever the token wasn't at the start of the expression. Every other token type in the lexer already uses start + len(...). Fixes the quoted-identifier case from the report; the same bug also affects backtick literals and raw string literals, so those are fixed and covered too. Search results aren't affected, only the position information.
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.
Fixes #380.
_consume_literal,_consume_quoted_identifier, and_consume_raw_string_literalall set the token'sendtotoken_len(the token's length) instead ofstart + token_len, soendwas wrong — and less thanstart— whenever the token wasn't at the start of the expression:Every other token type in the lexer already uses
start + len(...)forend(see the other'end':assignments inlexer.py).The reported issue was specifically about quoted identifiers, but the same copy-pasted bug affects two more token types: backtick literals (
_consume_literal) and raw string literals (_consume_raw_string_literal). Fixed and covered all three rather than just the one reported.Search results aren't affected, only the position information (
start/end), so this shouldn't change behavior for anyone who isn't inspecting raw token positions.