Decode \X escapes immediately#9245
Merged
Merged
Conversation
We forgot to decode (i.e. turn into nice wchar_t codepoints) "byte_literal" escape sequences. This meant that e.g. ```fish string match ö \Xc3\Xb6 math 5 \X2b 5 ``` didn't work, but `math 5 \x2b 5` did, and would print the wonderful error: ``` math: Error: Missing operator '5 + 5' ^ ``` So, instead, we decode eagerly.
mqudsi
reviewed
Sep 29, 2022
\X escapes immediately
Contributor
|
the diff reads fine when ignoring whitespace |
Contributor
|
Just to share something that's helped me: I manually use difftastic from time-to-time for looking at patches like this, as it is AST-aware (or at least scope-aware) and can ignore superfluous changes like addition/removal of braces (when it doesn't change meaning), an if condition causing the entire resulting scope to be marked as changed, changes to hard-wrapped lines, etc. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
We forgot to decode (i.e. turn into nice wchar_t codepoints) "byte_literal" escape sequences. This meant that e.g.
didn't work, and the latter would print the wonderful error:
In contrast,
math 5 \x2b 5works because\xis currently not "byte_literal" - it's seen as a codepoint number.So, instead, we decode eagerly.
TODOs:
Sidenote: The diff is an absolute mess - what I did was:
whileloop so we cancontinue\Xescaped valuesif (errored) return none()into the loop\X) put the value into the buffer andcontinueif there's another\Xfollowing.A reasonably simple change, but because of the additional indentation this touched most of
read_unquoted_escape. Sorry about that!