Skip to content

Commit

Permalink
[ruby/yarp] Fix invalid unescape sequence error for lower w
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmaissroff authored and matzbot committed Jun 21, 2023
1 parent fcf2f5a commit b0a3a6a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 2 additions & 0 deletions test/yarp/fixtures/arrays.txt
Expand Up @@ -78,3 +78,5 @@ foo[bar] = baz
%w{one two three}

%x{one two three}

%w[\C:]
9 changes: 7 additions & 2 deletions test/yarp/snapshots/arrays.txt
@@ -1,6 +1,6 @@
ProgramNode(0...502)(
ProgramNode(0...511)(
[],
StatementsNode(0...502)(
StatementsNode(0...511)(
[ArrayNode(0...4)(
[SplatNode(1...3)(
(1...2),
Expand Down Expand Up @@ -691,6 +691,11 @@ ProgramNode(0...502)(
(488...501),
(501...502),
"one two three"
),
ArrayNode(504...511)(
[StringNode(507...510)(nil, (507...510), nil, "\\C:")],
(504...507),
(510...511)
)]
)
)
9 changes: 8 additions & 1 deletion yarp/yarp.c
Expand Up @@ -6477,7 +6477,14 @@ parser_lex(yp_parser_t *parser) {
// If we hit escapes, then we need to treat the next token
// literally. In this case we'll skip past the next character and
// find the next breakpoint.
size_t difference = yp_unescape_calculate_difference(breakpoint, parser->end, YP_UNESCAPE_ALL, false, &parser->error_list);

yp_unescape_type_t unescape_type;
if (parser->lex_modes.current->as.list.interpolation) {
unescape_type = YP_UNESCAPE_ALL;
} else {
unescape_type = YP_UNESCAPE_MINIMAL;
}
size_t difference = yp_unescape_calculate_difference(breakpoint, parser->end, unescape_type, false, &parser->error_list);

// If the result is an escaped newline, then we need to
// track that newline.
Expand Down

0 comments on commit b0a3a6a

Please sign in to comment.