diff --git a/test/yarp/fixtures/arrays.txt b/test/yarp/fixtures/arrays.txt index e277ad5b34d0f7..057a73abf65a20 100644 --- a/test/yarp/fixtures/arrays.txt +++ b/test/yarp/fixtures/arrays.txt @@ -78,3 +78,5 @@ foo[bar] = baz %w{one two three} %x{one two three} + +%w[\C:] diff --git a/test/yarp/snapshots/arrays.txt b/test/yarp/snapshots/arrays.txt index 1f0360f965e7d8..219573ccba6a3a 100644 --- a/test/yarp/snapshots/arrays.txt +++ b/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), @@ -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) )] ) ) diff --git a/yarp/yarp.c b/yarp/yarp.c index d75477978fdaa8..db9a7ba5625f8d 100644 --- a/yarp/yarp.c +++ b/yarp/yarp.c @@ -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.