Skip to content

Commit

Permalink
Correct reference error message (#1855)
Browse files Browse the repository at this point in the history
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"`
  • Loading branch information
aaronmunsters committed Feb 21, 2022
1 parent 1d28514 commit 517c672
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions boa/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 517c672

Please sign in to comment.