From 517c6724c9d674bdb5b3781a1117662222c26f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=C3=A4ron=20Munsters?= Date: Mon, 21 Feb 2022 20:50:38 +0000 Subject: [PATCH] Correct reference error message (#1855) This Pull Request fixes/closes the incorrect message thrown for the following code: ```javascript "use strict"; foo = "bar"; ``` Which would throw the following before the change (incorrect): `Uncaught "ReferenceError": "binding already exists: foo"` And would throw the following after the change (correct): `Uncaught "ReferenceError": "assignment to undeclared variable foo"` --- boa/src/vm/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/boa/src/vm/mod.rs b/boa/src/vm/mod.rs index 670fdb1795..4bee56fef1 100644 --- a/boa/src/vm/mod.rs +++ b/boa/src/vm/mod.rs @@ -459,8 +459,9 @@ impl Context { let exists = self.global_bindings_mut().contains_key(&key); if !exists && (self.strict() || self.vm.frame().code.strict) { - return self - .throw_reference_error(format!("binding already exists: {key}")); + return self.throw_reference_error(format!( + "assignment to undeclared variable {key}" + )); } let success = crate::object::internal_methods::global::global_set_no_receiver(