Skip to content

Commit

Permalink
Fix reference checks after delete (#1095)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed Feb 20, 2022
1 parent b271cef commit e31a0a7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 33 deletions.

This file was deleted.

7 changes: 5 additions & 2 deletions Jint/Runtime/Environments/GlobalEnvironmentRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ public override void SetMutableBinding(string name, JsValue value, bool strict)
{
// fast inlined path as we know we target global, otherwise would be
// _objectRecord.SetMutableBinding(name, value, strict);
if (!_global.Set(name, value) && strict)
var property = JsString.Create(name);
if (strict && !_global.HasProperty(property))
{
ExceptionHelper.ThrowTypeError(_engine.Realm);
ExceptionHelper.ThrowReferenceError(_engine.Realm, name);
}

_global.Set(property, value);
}
}

Expand Down
6 changes: 4 additions & 2 deletions Jint/Runtime/Environments/ObjectEnvironmentRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ public override void SetMutableBinding(string name, JsValue value, bool strict)

internal override void SetMutableBinding(in BindingName name, JsValue value, bool strict)
{
if (!_bindingObject.Set(name.StringValue, value) && strict)
if (strict && !_bindingObject.HasProperty(name.StringValue))
{
ExceptionHelper.ThrowTypeError(_engine.Realm);
ExceptionHelper.ThrowReferenceError(_engine.Realm, name.Key);
}

_bindingObject.Set(name.StringValue, value);
}

public override JsValue GetBindingValue(string name, bool strict)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ protected override ExpressionResult EvaluateInternal(EvaluationContext context)
var leftNumeric = TypeConverter.ToNumeric(left);
var rightNumeric = TypeConverter.ToNumeric(right);

if (leftNumeric.IsNumber())
if (leftNumeric.IsNumber() && rightNumeric.IsNumber())
{
result = JsNumber.Create(leftNumeric.AsNumber() * rightNumeric.AsNumber());
}
Expand Down

0 comments on commit e31a0a7

Please sign in to comment.