[P2] Compiler: Array prototype calls read arguments.length twice
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #3510 de @nickna — fusionado
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- csharp, typescript
- Área
- compilers
Línea de trabajo
Start by reading the descriptor-aware compiled arguments work in pull request #3510 and compare its standalone assembly at 66d78c4ff with clean main at cabb41636. Trace the inline calls to Array.prototype.map, filter, flat, and toReversed, then run the supplied reproducer and the related compiler tests. Done means each method reads the live arguments length once while preserving its result length validation and element-read order.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The descriptor-aware compiled arguments work in #3510 introduced a second read of arguments.length in inline calls to Array.prototype.map, filter, flat, and toReversed. The precheck reads the length, then the arguments materializer reads it again. A getter can observe both reads and return different lengths.
function read(method) {
function f(a, b) {
const args = arguments;
let count = 0;
Object.defineProperty(args, "length", {
get() { count++; return count === 1 ? 2 : 1; }
});
let result;
if (method === "map") result = Array.prototype.map.call(args, value => value);
if (method === "filter") result = Array.prototype.filter.call(args, value => true);
if (method === "flat") result = Array.prototype.flat.call(args);
if (method === "toReversed") result = Array.prototype.toReversed.call(args);
console.log(method, count, result.join(","));
}
f(2, 1);
}
for (const method of ["map", "filter", "flat", "toReversed"]) read(method);
Node v22.23.2 reads the length once for each method. The outputs contain both entries (2,1 for map/filter/flat and 1,2 for toReversed). The verified standalone assembly on #3510 at 66d78c4ff reads it twice and uses the second length. Clean main at cabb41636 reads it once but falls back to backing storage, which separately loses descriptor-backed values.
Expected: use one live length read and preserve method-specific result length validation and element-read order. The distinct Array.prototype.with index validation and allocation failure is tracked in #3531.
- Lenguaje dominante
- C#
- Estrellas
- 156
- Forks
- 4
- Merge medio
- 15 h 35 min
- PR fusionados (30 d)
- 43
Preparar el entorno
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de nickna/SharpTS
-
Dificultad 3/5 1-2 días Aptitud para principiantes 57/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
Los mantenedores suelen responder en 1 día
-
Compiled strict async function declarations lack the throwing callee accessorPosiblemente ocupada @nickna la tomó hoy. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 69/100
Los mantenedores suelen responder en 1 día
Todos los issues de nickna/SharpTS
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dotnet/wpf#12108 · 3 reacciones ·
Los mantenedores suelen responder en 1 día
-
:watch: Not Triaged dotnet/svc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
area:build type:chore
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
csharp good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
python triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/semantic-kernel#14753 ·
Los mantenedores suelen responder en 5 días