Browse Source

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"`
pull/1856/head
Aäron Munsters 3 years ago
parent
commit
517c6724c9
  1. 5
      boa/src/vm/mod.rs

5
boa/src/vm/mod.rs

@ -459,8 +459,9 @@ impl Context {
let exists = self.global_bindings_mut().contains_key(&key); let exists = self.global_bindings_mut().contains_key(&key);
if !exists && (self.strict() || self.vm.frame().code.strict) { if !exists && (self.strict() || self.vm.frame().code.strict) {
return self return self.throw_reference_error(format!(
.throw_reference_error(format!("binding already exists: {key}")); "assignment to undeclared variable {key}"
));
} }
let success = crate::object::internal_methods::global::global_set_no_receiver( let success = crate::object::internal_methods::global::global_set_no_receiver(

Loading…
Cancel
Save