Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Partial application moves its arguments into the generated closure

Offen
#8,932 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@cknitt arbeitet bereits daran.

Seit 20.10.2026.

  • #8936 von @cknitt — offen

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
25/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
javascript
Bereich
compilers

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
ReScript
Sterne
7.5k
Forks
483
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
164

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus rescript-lang/rescript

Alle Issues in rescript-lang/rescript

Ähnliche Issues

Weitere Issues zu Compilers

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.