Compiled write-captured block-scope shadow shares name-keyed $functionDC (residual of #767/#674)
Los mantenedores suelen responder en 1 día
Ya se ha fusionado un pull request relacionado.
- #849 de @nickna — fusionado
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- csharp, typescript
- Área
- compilers
Línea de trabajo
Read Compilation/ClosureAnalyzer.cs and Compilation/LocalVariableResolver.cs alongside the function and suspension emitters listed in the issue. Trace how the inner shadow is renamed for body access and how the arrow resolves its captured r; compare compiled output with the supplied generator repro. Done means compiled mode yields 6,6,100 and the fix covers the listed async and generator contexts.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
Residual left open by #767. A nested-block let/const that shadows an enclosing binding and is written by a nested closure leaks in compiled mode in all suspension contexts (generator #674, async-gen #725, async function). Read-only captures are fixed by #767 for (async) generators; the write case is off-limits everywhere.
Repro
function* mut(): Generator<number> {
const r = 100;
{
let r = 5;
const f = () => { r = r + 1; return r; };
yield f();
yield r;
}
yield r;
}
console.log([...mut()].join(","));
- Interpreted:
6,6,100(correct) - Compiled:
6,6,6(wrong — inner and outerrcollide on the name-keyed$functionDCfield)
Root cause
A captured-AND-mutated local is lifted into the name-keyed $functionDC (#674/#725) so the closure's write and the body share storage. The #711/#767 renamer gives the inner shadow its own storage (<r>__bs0) and routes the body's inner-r access there, but the DC field stays keyed r, so the closure read/write and the outer binding collide. Renaming only the body side would desync the closure, so write-captured shadows are kept off-limits to renaming in every mode.
Suggested fix (Follow-up B)
Make the function DC rename-aware / per-binding: register the DC field under the renamed storage name (<r>__bs0), key CapturedFunctionLocals / FunctionDisplayClassFields by it (body side already retokens via #711), and update the arrow's capture resolution so its capture name r maps to functionDC.<r>__bs0 — the "program-wide ClosureAnalyzer rename awareness" the #767 deferral named. Spans DC registration + body emit + arrow resolver + ClosureAnalyzer/LocalVariableResolver.
Files: Compilation/ILCompiler.Functions.cs, Compilation/ILCompiler.Generators.cs, Compilation/ILCompiler.AsyncGenerators.cs, Compilation/ILCompiler.Async.cs, Compilation/ClosureAnalyzer.cs, Compilation/LocalVariableResolver.cs.
Priority
Low / astronomically rare, but highest blast radius of the closure-residual fixes (edits the capture hub #674/#625/#682/#725 depend on). No TypeScript conformance impact (TSConformance type-checker only; Test262 interpreter already correct). Subsumes #837. Found while implementing #767.
- Lenguaje dominante
- C#
- Estrellas
- 156
- Forks
- 4
- Merge medio
- 14 h 45 min
- PR fusionados (30 d)
- 40
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 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Compiled require(node:buffer) exposes non-callable isUtf8, isAscii, transcode and SlowBufferAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 57/100
Los mantenedores suelen responder en 1 día
Todos los issues de nickna/SharpTS
Issues similares
-
elsa 3
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
elsa-workflows/elsa-core#9349 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
PereViader/ManualDi#200 ·
-
fix: the live capture mode of check-native-browser.mjs ignores PLAYWRIGHT_CHROMIUM_EXECUTABLEAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
Forrest-Technologies/drover#1040 ·
Los mantenedores suelen responder en 1 día
-
todo
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
tonybaloney/CSnakes#864 ·