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

Array.of has to use defineOwnProperty instead of set #1381

Merged
merged 1 commit into from
Aug 26, 2023
Merged
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
12 changes: 10 additions & 2 deletions src/org/mozilla/javascript/NativeArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -848,8 +848,16 @@ private static Object js_of(Context cx, Scriptable scope, Scriptable thisObj, Ob
final Scriptable result =
callConstructorOrCreateArray(cx, scope, thisObj, args.length, true);

for (int i = 0; i < args.length; i++) {
defineElem(cx, result, i, args[i]);
if (cx.getLanguageVersion() >= Context.VERSION_ES6 && result instanceof ScriptableObject) {
ScriptableObject desc = ScriptableObject.buildDataDescriptor(result, null, EMPTY);
for (int i = 0; i < args.length; i++) {
desc.put("value", desc, args[i]);
((ScriptableObject) result).defineOwnProperty(cx, i, desc);
}
} else {
for (int i = 0; i < args.length; i++) {
defineElem(cx, result, i, args[i]);
}
}
setLengthProperty(cx, result, args.length);

Expand Down
4 changes: 1 addition & 3 deletions testsrc/test262.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a configuration file for Test262SuiteTest.java. See ./README.md for more info about this file

built-ins/Array 179/2670 (6.7%)
built-ins/Array 177/2670 (6.63%)
from/calling-from-valid-1-noStrict.js non-strict Spec pretty clearly says this should be undefined
from/elements-deleted-after.js Checking to see if length changed, but spec says it should not
from/iter-map-fn-this-non-strict.js non-strict Error propagation needs work in general
Expand All @@ -18,9 +18,7 @@ built-ins/Array 179/2670 (6.7%)
length/define-own-prop-length-coercion-order-set.js {unsupported: [Reflect, Reflect.set]}
length/define-own-prop-length-no-value-order.js {unsupported: [Reflect]}
length/define-own-prop-length-overflow-order.js
of/does-not-use-set-for-indices.js
of/proto-from-ctor-realm.js
of/return-abrupt-from-data-property.js Object.preventExtensions doesn't seem to throw
of/return-abrupt-from-data-property-using-proxy.js {unsupported: [Proxy]}
prototype/concat/arg-length-exceeding-integer-limit.js {unsupported: [Proxy]}
prototype/concat/Array.prototype.concat_large-typed-array.js new
Expand Down
Loading