Browse Source

Fix parse error throwing a `TypeError`, instead of `SyntaxError` (#748)

pull/765/head
Saquib 4 years ago committed by GitHub
parent
commit
2feb72a0e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      boa/src/context.rs
  2. 6
      boa/src/exec/tests.rs

2
boa/src/context.rs

@ -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.

6
boa/src/exec/tests.rs

@ -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\"");
}

Loading…
Cancel
Save