Skip to content

Commit

Permalink
Fix for #616
Browse files Browse the repository at this point in the history
Affects strict mode only.

No longer prematurely throws a TypeError in ScriptableObject.putImpl(Object,int,Scriptable,Object) when instance member isExtensible is false.

Instead, now it first queries the slotmap, so that if a GetterSlot instance is returned, any present setter may be called. All other outcomes of this method should be unaffected.
  • Loading branch information
stijnkliemesch committed Nov 8, 2019
1 parent bee350c commit 8462669
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/org/mozilla/javascript/ScriptableObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -2804,20 +2804,18 @@ private boolean putImpl(Object key, int index, Scriptable start,
{
// This method is very hot (basically called on each assignment)
// so we inline the extensible/sealed checks below.
if (!isExtensible) {
Context cx = Context.getContext();
if (cx.isStrictMode()) {
throw ScriptRuntime.typeError0("msg.not.extensible");
}
}
Slot slot;
if (this != start) {
slot = slotMap.query(key, index);
if(!isExtensible && Context.getContext().isStrictMode() && (slot == null || !(slot instanceof GetterSlot)))
throw ScriptRuntime.typeError0("msg.not.extensible");
if (slot == null) {
return false;
}
} else if (!isExtensible) {
slot = slotMap.query(key, index);
if(Context.getContext().isStrictMode() && (slot == null || !(slot instanceof GetterSlot)))
throw ScriptRuntime.typeError0("msg.not.extensible");
if (slot == null) {
return true;
}
Expand Down

0 comments on commit 8462669

Please sign in to comment.