Skip to content

Commit

Permalink
Fix parse error throwing a TypeError, instead of SyntaxError (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsaquib8 authored Oct 1, 2020
1 parent 672aa11 commit 2feb72a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion boa/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ impl Context {

let result = match Self::parser_expr(src) {
Ok(expr) => expr.run(self),
Err(e) => self.throw_type_error(e),
Err(e) => self.throw_syntax_error(e),
};

// The main_timer needs to be dropped before the BoaProfiler is.
Expand Down
6 changes: 6 additions & 0 deletions boa/src/exec/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,3 +1377,9 @@ fn test_conditional_op() {
let scenario = "1 === 2 ? 'a' : 'b'";
assert_eq!(&exec(scenario), "\"b\"");
}

#[test]
fn test_identifier_op() {
let scenario = "break = 1";
assert_eq!(&exec(scenario), "\"SyntaxError\": \"expected token \'identifier\', got \'=\' in binding identifier at line 1, col 7\"");
}

0 comments on commit 2feb72a

Please sign in to comment.