Skip to content

Commit d7211d6

Browse files
authored
Handle nested unclosed template literal strings
tentative fix for rescript-lang#432 (rescript-lang#435)
1 parent 30a978d commit d7211d6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

syntax/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ lib/*
77
!lib/README.md
88
.vscode/settings.json
99
# each person has its own preferences
10+
_build

syntax/src/res_scanner.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,11 @@ let scanTemplateLiteralToken scanner =
487487
| _ ->
488488
next scanner;
489489
scan ())
490-
| ch when ch == hackyEOFChar ->
490+
| ch when ch = hackyEOFChar ->
491491
let endPos = position scanner in
492492
scanner.err ~startPos ~endPos Diagnostics.unclosedTemplate;
493493
Token.TemplateTail(
494-
(String.sub [@doesNotRaise]) scanner.src startOff (scanner.offset - 1 - startOff)
494+
(String.sub [@doesNotRaise]) scanner.src startOff (max (scanner.offset - 1 - startOff) 0)
495495
)
496496
| _ ->
497497
next scanner;

0 commit comments

Comments
 (0)