Partial application moves its arguments into the generated closure
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- compilers
Línea de trabajo
Start in compiler/ml/translcore.ml at transl_apply's uncurried_partial_application branch, then compare its argument handling with build_apply's protect path. Check the compiler tests for partial application, including cases with await, side effects, and yield. Done means arguments are evaluated once at the partial application site and remain valid outside the generated closure.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Partial application with ... puts the supplied arguments inside the closure it creates, instead of evaluating them first.
let add = (a, b, c) => a + b + c
let f = async p => {
let h = add(await p, ...)
h(1, 2) + h(3, 4)
}
compiles to
async function f(p) {
let h = (extra, extra$1) => add(await p, extra, extra$1);
return h(1, 2) + h(3, 4) | 0;
}
await inside a non-async arrow is a JavaScript syntax error, so the module fails to load.
The same placement also re-evaluates the argument on every call:
let g = () => {
let h = add(next(), ...)
h(1, 2) + h(1, 2)
}
function g() {
let h = (extra, extra$1) => add(next(), extra, extra$1);
return h(1, 2) + h(1, 2) | 0;
}
Here next() runs twice, once for each call of h.
When h is used only once, the optimizer inlines it and both problems disappear, which may be why this hasn't been noticed.
Expected: the arguments are evaluated once, where the partial application happens:
let arg = await p;
let h = (extra, extra$1) => add(arg, extra, extra$1);
Cause: in compiler/ml/translcore.ml, transl_apply's uncurried_partial_application branch puts the translated arguments directly into the body of the new function. The optional-argument path (build_apply) already let-binds non-trivial arguments outside the closure (protect); the ... path should do the same.
This also blocks generator functions, since a yield would be moved into the closure the same way.
Reproduced on master (8556f0ad72).
- Lenguaje dominante
- ReScript
- Estrellas
- 7.5k
- Forks
- 483
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 164
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
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 rescript-lang/rescript
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
rescript-lang/rescript#8938 ·
Los mantenedores suelen responder en 1 día
-
RFC: Generator functionsAbiertodiscussion enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
rescript-lang/rescript#8934 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
rescript-lang/rescript#8910 ·
Los mantenedores suelen responder en 1 día
-
Nested JSX components under React Server Components: derive flat exports from the signaturePosiblemente ocupada @cknitt la tomó hace 3 días. Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
rescript-lang/rescript#8901 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
rescript-lang/rescript#8897 ·
Los mantenedores suelen responder en 1 día
Todos los issues de rescript-lang/rescript
Issues similares
-
bug priority: P2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
confirmed generated by fuzzer llvm:optimizations miscompilation
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
llvm/llvm-project#234325 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
Support underscore in modulesAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
gren-lang/compiler-common#41 ·
-
area:codegen backend:hlsl bug coverage direction:output
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día