[P2] Compiler: indirect toSorted calls ignore arguments.length

Aperta
#3,534 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
csharp, typescript
Ambito
compilers

Direzione di ricerca

Start by comparing the compiled indirect Array.prototype.toSorted.apply(args, []) path with the inline .call(args) path and the descriptor-aware generic helper mentioned in the issue. Run the unchecked classic JavaScript reproducer with --no-tsconfig --noLib and compare its output with Node v22.23.2. Done means the compiled indirect call reads the JavaScript length property once and produces 2 1.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Compiled dynamic Array.prototype.toSorted calls use the backing arguments storage count instead of the JavaScript length property.

function f(a, b) {
    const args = arguments;
    let reads = 0;
    Object.defineProperty(args, "length", { get() { reads++; return 1; } });
    const sortCopy = Array.prototype.toSorted;
    console.log(sortCopy.apply(args, []).join(","), reads);
}
f(2, 1);

Node v22.23.2 prints 2 1. The compiled standalone outputs on clean main at cabb41636 and #3510 at 66d78c4ff both print 1,2 0. Both assemblies passed full saved IL verification. Run the source as an unchecked classic .js file with --no-tsconfig --noLib.

The indirect apply path differs from the inline Array.prototype.toSorted.call(args) path, which uses the descriptor-aware generic helper in #3510. Found while auditing related length checks in #3533.

Lingua principale
C#
Stelle
156
Fork
4
Merge medio
15h 49m
PR unite (30g)
42

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nickna/SharpTS

Tutte le issue di nickna/SharpTS

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.