Skip to content

Commit

Permalink
fix: error for more unterminated nodes (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Apr 18, 2024
1 parent afe9c68 commit 4b775a8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/swc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ pub fn ensure_no_specific_syntax_errors(parsed_source: &ParsedSource) -> Result<
SyntaxError::ExpectedDigit { .. } |
SyntaxError::ExpectedSemiForExprStmt { .. } |
SyntaxError::ExpectedUnicodeEscape |
// various unterminated
SyntaxError::UnterminatedStrLit |
SyntaxError::UnterminatedBlockComment |
SyntaxError::UnterminatedJSXContents |
SyntaxError::UnterminatedRegExp |
SyntaxError::UnterminatedTpl |
// unexpected token
SyntaxError::Unexpected { .. } |
// Merge conflict marker
Expand Down Expand Up @@ -293,6 +299,19 @@ mod tests {
);
}

#[test]
fn it_should_error_for_exected_string_literal() {
run_non_fatal_diagnostic_test(
"./test.ts",
"var foo = 'test",
concat!(
"Unterminated string constant at file:///test.ts:1:11\n\n",
" var foo = 'test\n",
" ~~~~~"
),
);
}

#[test]
fn it_should_error_for_merge_conflict_marker() {
run_non_fatal_diagnostic_test(
Expand Down

0 comments on commit 4b775a8

Please sign in to comment.