Skip to content

Commit

Permalink
fix: disallow semi injection before a backtick
Browse files Browse the repository at this point in the history
  • Loading branch information
jackschu authored Jul 20, 2024
1 parent b1fd0b2 commit a92640f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static bool scan_automatic_semicolon(TSLexer *lexer, bool comment_condition, boo
}

switch (lexer->lookahead) {
case '`':
case ',':
case ':':
case ';':
Expand Down
9 changes: 8 additions & 1 deletion test/corpus/expressions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Template strings

`\ `;

`The command \`git ${args.join(' ')}\` exited with an unexpected code: ${exitCode}. The caller should either handle this error, or expect that exit code.`
`The command \`git ${args.join(' ')}\` exited with an unexpected code: ${exitCode}. The caller should either handle this error, or expect that exit code.`;

`\\`;

Expand Down Expand Up @@ -154,10 +154,17 @@ Function calls with template strings
============================================

f `hello`;
f
`hello`;

---

(program
(expression_statement
(call_expression
(identifier)
(template_string
(string_fragment))))
(expression_statement
(call_expression
(identifier)
Expand Down

0 comments on commit a92640f

Please sign in to comment.