Skip to content

Commit

Permalink
fix hang for incomplete raw strings
Browse files Browse the repository at this point in the history
  • Loading branch information
resolritter authored and alex-pinkus committed Apr 6, 2022
1 parent 21bb67e commit 154f036
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions corpus/literals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,24 @@ let _ = ##"Hello, so-called "world"!"##
(raw_string_literal
(raw_str_end_part))))

================================================================================
Doesn't hang for incomplete raw strings (issue #146)
================================================================================

let _ = #"Foo"

---

(source_file
(property_declaration
(value_binding_pattern
(non_binding_pattern
(wildcard_pattern)))
(ERROR
(UNEXPECTED '"'))
(line_string_literal
(line_str_text))))

================================================================================
Raw strings with interpolation
================================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ static bool eat_raw_str_part(
uint8_t last_char = '\0';
lexer->mark_end(lexer); // We always want to parse thru the start of the string so far
// Advance through anything that isn't a hash symbol, because we want to count those.
while (lexer->lookahead != '#') {
while (lexer->lookahead != '#' && lexer->lookahead != '\0') {
last_char = lexer->lookahead;
advance(lexer);
if (last_char != '\\') {
Expand Down

0 comments on commit 154f036

Please sign in to comment.