Closed Bug 1658308 Opened 4 years ago Closed 4 years ago

Implement the .at() proposal

Categories

(Core :: JavaScript: Standard Library, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
Tracking Status
firefox85 --- fixed

People

(Reporter: yulia, Assigned: evilpie)

References

(Blocks 1 open bug, )

Details

(Keywords: dev-doc-complete)

Attachments

(5 files, 1 obsolete file)

https://github.com/tabatkins/proposal-item-method

The proposal is currently on Stage 2.

Assignee: nobody → evilpies

I noticed this while looking at the iongraph for a simple item call
with a constant parameter. The input is boxed because before optimization
it is apparently an untyped PHI.

Depends on D90732

Attachment #9176631 - Attachment description: Bug 1658308 - Implement Array.prototype.item and %TypedArray%.prototype.item → Bug 1658308 - Implement Array.prototype.item and %TypedArray%.prototype.item in Nightly. r?anba

I only added some very basic tests here under the assumption that
test262 is going to add a broader range of tests.

Depends on D90732

Attachment #9176633 - Attachment description: Bug 1658308 - Constant folding for boxed MToNumberInt32 inputs. → Bug 1658308 - Constant folding for boxed MToNumberInt32 inputs. r?jandem
Component: JavaScript Engine → JavaScript: Standard Library

Apparently the item proposal advanced to Stage 3, but with String.prototype.item still included. However there seems to be some agreement that this should probably not be part of the proposal at least without a better justification: https://github.com/tc39/proposal-item-method/issues/20

Keywords: dev-doc-needed
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/f43cdaab8611
Implement Array.prototype.item and %TypedArray%.prototype.item in Nightly. r=anba
https://hg.mozilla.org/integration/autoland/rev/cd81e5f20c95
Some basic item tests. r=anba
https://hg.mozilla.org/integration/autoland/rev/37ddb997bbf6
Constant folding for boxed MToNumberInt32 inputs. r=jandem
Regressions: 1667649
Regressions: 1668342
Depends on: 1668640
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/5bc024234126
Implement String.prototyp.item in Nightly. r=anba
No longer depends on: 1668640

André pointed out that we will need to handle Array.prototype[@@unscopables] at some point: https://github.com/tc39/proposal-item-method/issues/30.

I opened another issue for the web compatibility issue with Yui2 that broke bugzilla: https://github.com/tc39/proposal-item-method/issues/31

Regressions: 1669867
Attachment #9179940 - Attachment is obsolete: true

There are too many web compatibility issues. Keeping this on Nightly is not going
to be useful.

Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/8b1680a2b965
Backout Array.prototype.item and %TypedArray%.prototype.item.
Summary: Implement the .item proposal → Implement the .at proposal
Summary: Implement the .at proposal → Implement the .at() proposal
Pushed by evilpies@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/aac43ddfdb12
Implement the .at() proposal. r=jandem
Status: NEW → RESOLVED
Closed: 4 years ago
Keywords: leave-open
Resolution: --- → FIXED

It doesn't seem to work with this test from http://kangax.github.io/compat-table/esnext/ :
return [
'Int8Array',
'Uint8Array',
'Uint8ClampedArray',
'Int16Array',
'Uint16Array',
'Int32Array',
'Uint32Array',
'Float32Array',
'Float64Array',
'BigInt64Array',
'BigUint64Array'
].every(function (TypedArray) {
var Constructor = globalThis[TypedArray];
if (typeof Constructor !== 'function') {
return true;
}
var arr = new Constructor([1, 2, 3]);
return arr.at(0) === 1
&& arr.at(-3) === 1
&& arr.at(1) === 2
&& arr.at(-2) === 2
&& arr.at(2) === 3
&& arr.at(-1) === 3
&& arr.at(3) === undefined
&& arr.at(-4) === undefined;
});

Should it?

The error is "can't convert 1 to BigInt". Coming from doing new BigInt64Array([1, 2, 3]) (via new Constructor ..) So the test is wrong and the failure is unrelated to at.

Blocks: 1681371

Setting this to dev-doc-complete. @rumyra documented it, the details are all available at https://github.com/mdn/content/issues/307, and the pages should appear on MDN in the next 24 hours or so.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: