Skip to content

Commit 4b775a8

Browse files
authored
fix: error for more unterminated nodes (#628)
1 parent afe9c68 commit 4b775a8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/swc.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ pub fn ensure_no_specific_syntax_errors(parsed_source: &ParsedSource) -> Result<
124124
SyntaxError::ExpectedDigit { .. } |
125125
SyntaxError::ExpectedSemiForExprStmt { .. } |
126126
SyntaxError::ExpectedUnicodeEscape |
127+
// various unterminated
128+
SyntaxError::UnterminatedStrLit |
129+
SyntaxError::UnterminatedBlockComment |
130+
SyntaxError::UnterminatedJSXContents |
131+
SyntaxError::UnterminatedRegExp |
132+
SyntaxError::UnterminatedTpl |
127133
// unexpected token
128134
SyntaxError::Unexpected { .. } |
129135
// Merge conflict marker
@@ -293,6 +299,19 @@ mod tests {
293299
);
294300
}
295301

302+
#[test]
303+
fn it_should_error_for_exected_string_literal() {
304+
run_non_fatal_diagnostic_test(
305+
"./test.ts",
306+
"var foo = 'test",
307+
concat!(
308+
"Unterminated string constant at file:///test.ts:1:11\n\n",
309+
" var foo = 'test\n",
310+
" ~~~~~"
311+
),
312+
);
313+
}
314+
296315
#[test]
297316
fn it_should_error_for_merge_conflict_marker() {
298317
run_non_fatal_diagnostic_test(

0 commit comments

Comments
 (0)