From 2feb72a0e4e407f536ed4092e11c72ea968dcc4b Mon Sep 17 00:00:00 2001 From: Saquib Date: Fri, 2 Oct 2020 00:41:46 +0530 Subject: [PATCH] Fix parse error throwing a `TypeError`, instead of `SyntaxError` (#748) --- boa/src/context.rs | 2 +- boa/src/exec/tests.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/boa/src/context.rs b/boa/src/context.rs index cb2b6abf9f..aa7b64ddbc 100644 --- a/boa/src/context.rs +++ b/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. diff --git a/boa/src/exec/tests.rs b/boa/src/exec/tests.rs index 4927b74ef2..7ffd08e366 100644 --- a/boa/src/exec/tests.rs +++ b/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\""); +}