Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Fix setting properties inside with blocks #2847

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions boa_engine/src/environments/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ impl Context<'_> {
mut binding_index: usize,
name: Identifier,
value: JsValue,
strict: bool,
) -> JsResult<bool> {
for env_index in (environment_index + 1..self.vm.environments.stack.len()).rev() {
let env = self.environment_expect(env_index);
Expand Down Expand Up @@ -983,7 +984,7 @@ impl Context<'_> {
continue;
}
}
return o.set(key, value, true, self);
return o.set(key, value, strict, self);
}
}
}
Expand Down Expand Up @@ -1017,6 +1018,7 @@ impl Context<'_> {
&mut self,
name: Identifier,
value: &JsValue,
strict: bool,
) -> JsResult<bool> {
for env_index in (0..self.vm.environments.stack.len()).rev() {
let env = self.environment_expect(env_index);
Expand Down Expand Up @@ -1056,7 +1058,7 @@ impl Context<'_> {
continue;
}
}
return o.set(key, value.clone(), true, self);
return o.set(key, value.clone(), strict, self);
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion boa_engine/src/vm/opcode/define/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ impl Operation for DefInitVar {
binding_locator.throw_mutate_immutable(context)?;

if binding_locator.is_global() {
if !context.put_value_if_global_poisoned(binding_locator.name(), &value)? {
if !context.put_value_if_global_poisoned(
binding_locator.name(),
&value,
context.vm.frame().code_block.strict,
)? {
let key = context
.interner()
.resolve_expect(binding_locator.name().sym())
Expand Down
7 changes: 6 additions & 1 deletion boa_engine/src/vm/opcode/set/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ impl Operation for SetName {
binding_locator.throw_mutate_immutable(context)?;

if binding_locator.is_global() {
if !context.put_value_if_global_poisoned(binding_locator.name(), &value)? {
if !context.put_value_if_global_poisoned(
binding_locator.name(),
&value,
context.vm.frame().code_block.strict,
)? {
let key: JsString = context
.interner()
.resolve_expect(binding_locator.name().sym())
Expand Down Expand Up @@ -55,6 +59,7 @@ impl Operation for SetName {
binding_locator.binding_index(),
binding_locator.name(),
value,
context.vm.frame().code_block.strict,
)? {
return Err(JsNativeError::reference()
.with_message(format!(
Expand Down