`Array.prototype.at` / `with` / `toReversed` / `toSorted` / `toSpliced` check `[[HasProperty]]` before reading elements
Maintainers usually reply within 5 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c, javascript
Research direction
In quickjs.c, inspect the slow paths in js_array_at, js_array_with, js_array_toReversed, js_array_toSpliced, and js_array_toSorted, and compare JS_TryGetPropertyInt64 with JS_GetPropertyInt64. Start by running the provided Proxy example with ./qjs; done means the methods use [[Get]] without triggering has traps and produce the expected values.
Written by the indexing model from the issue text.
Description
Array.prototype.at, with, toReversed, toSorted, and toSpliced read non-fast-array elements with [[HasProperty]] before [[Get]] instead of [[Get]] alone, so a Proxy receiver sees unexpected has trap calls and gets undefined whenever has returns false (for example, a virtual array Proxy with only a get trap).
// t.js
const v = new Proxy([], {
get(t, k, r) {
if (k === "length") return 3;
if (k === "0" || k === "1" || k === "2") return (Number(k) + 1) * 10;
return Reflect.get(t, k, r);
}
});
console.log(v[1], v.at(1), v.toReversed().map(String).join(","));
function run(name, f) {
const log = [];
f(new Proxy([1, 2, 3], { has(t, k) { log.push("has:" + String(k)); return Reflect.has(t, k); } }));
console.log(name + ": " + (log.length ? log.join(",") : "-"));
}
run("at", p => p.at(1));
run("with", p => p.with(0, 9));
run("toReversed", p => p.toReversed());
run("toSorted", p => p.toSorted());
run("toSpliced", p => p.toSpliced(0, 1));
Running ./qjs t.js prints:
20 undefined undefined,undefined,undefined
at: has:1
with: has:1,has:2
toReversed: has:2,has:1,has:0
toSorted: has:0,has:1,has:2
toSpliced: has:1,has:2
Expected (Node.js v26.13.0; Array.prototype.at):
20 20 30,20,10
at: -
with: -
toReversed: -
toSorted: -
toSpliced: -
In quickjs.c, the slow paths of js_array_at, js_array_with, js_array_toReversed, js_array_toSpliced, and js_array_toSorted call JS_TryGetPropertyInt64 (which checks JS_HasProperty before JS_GetPropertyValue) instead of JS_GetPropertyInt64.
Versions: QuickJS master 2519774 (2026-11-23) and release 2026-06-04 (3d5e064), Linux x86_64.
Credit: https://ucsbplse.github.io/
- Dominant language
- C
- Stars
- 11.1k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bellard/quickjs
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 5 days
-
`ArrayBuffer.prototype.transfer(n)` with n > maxByteLength throws TypeError instead of RangeErrorOpen
Difficulty 1/5 Under an hour Newbie friendliness 82/100
Maintainers usually reply within 5 days
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 5 days
-
Difficulty 3/5 1-2 days Newbie friendliness 69/100
Maintainers usually reply within 5 days
-
Difficulty 3/5 1-2 days Newbie friendliness 70/100
Maintainers usually reply within 5 days
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
bug severity: medium
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
AlessandroSangiuliano/Uros#1014 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
OpenXiangShan/NEMU#1314 ·
Maintainers usually reply within 1 day
-
`get_options()` repeats the first byte when hex-encoding octet stringsPossibly taken @rue19 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
OpenPrinting/cups#1830 ·
Maintainers usually reply within 1 day