Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Partial application moves its arguments into the generated closure

Ouverte
#8,932 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@cknitt y travaille déjà.

Depuis le 20/10/2026.

  • #8936 par @cknitt — ouverte

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
25/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
javascript
Domaine
compilers

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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).

Langage dominant
ReScript
Étoiles
7.5k
Forks
483
Merge moyen
1 j 2 h
PR mergées (30 j)
164

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de rescript-lang/rescript

Toutes les issues de rescript-lang/rescript

Issues similaires

Plus d'issues Compilers

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.