Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Partial application moves its arguments into the generated closure

Abierto
#8,932 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@cknitt ya está trabajando en esto.

Desde el 20/10/2026.

  • #8936 de @cknitt — abierto

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

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rescript-lang/rescript

Todos los issues de rescript-lang/rescript

Issues similares

Más issues de Compilers

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.