From 7f90829f88c6b184bf8275fb389ce666d2347b2f Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Tue, 8 Mar 2022 16:01:53 +0000 Subject: [PATCH] Compile StatementList after parse passes on negative tests (#1906) This fixes an issue with 262 negative tests, that should produce a syntax errors. Currently we only parse the test code is such cases. If the parsing does not return an error, we do not compile the code further. This caused some panics. Most of them are fixed by now, the last ones will be fixed with #1860. --- boa_tester/src/exec/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/boa_tester/src/exec/mod.rs b/boa_tester/src/exec/mod.rs index 1de2f60aba..6d4e367e11 100644 --- a/boa_tester/src/exec/mod.rs +++ b/boa_tester/src/exec/mod.rs @@ -180,9 +180,13 @@ impl Test { self.name ); - let mut interner = Interner::default(); - match Parser::new(self.content.as_bytes(), strict).parse_all(&mut interner) { - Ok(n) => (false, format!("{n:?}")), + let mut context = Context::default(); + context.set_strict_mode(strict); + match context.parse(self.content.as_bytes()) { + Ok(statement_list) => match context.compile(&statement_list) { + Ok(_) => (false, "StatementList compilation should fail".to_owned()), + Err(e) => (true, format!("Uncaught {e:?}")), + }, Err(e) => (true, format!("Uncaught {e}")), } }