Skip to content

Commit e2a2b2a

Browse files
committed
[GR-37536] PropertySetNode with setOwnProperty should behave like CreateDataProperty.
PullRequest: js/2379
2 parents d69709e + e7c0179 commit e2a2b2a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
load('assert.js');
9+
10+
class C { static name = 'foo'; }
11+
assertSame('foo', C.name);
12+
13+
class D { static length = 42; }
14+
assertSame(42, D.length);

graal-js/src/com.oracle.truffle.js/src/com/oracle/truffle/js/nodes/access/PropertySetNode.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,13 @@ private SetCacheNode createCachedPropertyNodeJSObject(Property property, JSDynam
10331033
Shape cacheShape = thisObj.getShape();
10341034
AbstractShapeCheckNode shapeCheck = createShapeCheckNode(cacheShape, thisObj, depth, false, false);
10351035

1036+
// isOwnProperty() means CreateDataProperty, i.e., we must redefine
1037+
// the property when the current flags do not match data property and
1038+
// when it is possible to do so (i.e. when it is configurable)
1039+
if (isOwnProperty() && JSAttributes.isConfigurable(property.getFlags()) && JSAttributes.configurableEnumerableWritable() != property.getFlags()) {
1040+
return new DataPropertyPutWithFlagsNode(key, shapeCheck);
1041+
}
1042+
10361043
if (JSProperty.isData(property)) {
10371044
return createCachedDataPropertyNodeJSObject(thisObj, depth, value, shapeCheck, property);
10381045
} else {

0 commit comments

Comments
 (0)