Repository navigation
Conversation
Changelog🐛 Bug fix
Semantic Diff1 commit · Full page Evaluate labelled arguments passed out of order in source order513572d · cknitt + Claude · Nov 19, 2026, 19:17 UTC
An argument is stable when it reads the same wherever it is evaluated: a constant, variable, function, constant constructor or module path. When the arguments that are not stable are out of source order and one of them can have side effects, the callee (unless it is an identifier) and those arguments are bound to temporaries in source order. A stable argument passed early, as in JS modified (out-of-order labelled arguments) let f = (x: int, ~extra: int, y: int) => [x, extra, y]
let r = f(~extra=b(), a(), c())
+let arg = b();
+let arg$1 = a();
+let arg$2 = c();
let r = [
- a(),
- b(),
- c()
+ arg$1,
+ arg,
+ arg$2
];Fixes #9340 Review
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 245c6abe9e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
✅ Compiler benchmarksAllocated wordsIn total: 639,870,498 → 640,034,127 (+0.03%). Generated projects: 629,805,682 → 629,823,070 (±0.00%).
InstructionsIn total: 9,215,369,410 → 9,217,643,071 (+0.02%).
Output sizeIn total: 25,920,835 → 25,922,113 (±0.00%). None of the 13 benchmarks changed by 0.1% or more. Pull request 513572d compared with base a826170 in this run. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9344 +/- ##
=======================================
Coverage 82.17% 82.18%
=======================================
Files 458 458
Lines 65678 65723 +45
=======================================
+ Hits 53971 54014 +43
- Misses 11707 11709 +2
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9344 |
Why:
An application lists its arguments in declared order. A labelled
argument passed before arguments declared ahead of it was therefore
evaluated after them, against the left-to-right order ReScript keeps
elsewhere (#9340, #9154).
An argument is stable when it reads the same wherever it is evaluated: a
constant, variable, function, constant constructor or module path. When
the arguments that are not stable are out of source order and one of them
can have side effects, the callee (unless it is an identifier) and those
arguments are bound to temporaries in source order. A stable argument
passed early, as in `fromArray(~id=module(IntCmp), range(0, 30))`, changes
nothing.
JS modified (out-of-order labelled arguments):
Example:
let f = (x: int, ~extra: int, y: int) => [x, extra, y]
let r = f(~extra=b(), a(), c())
Before (js):
let r = [
a(),
b(),
c()
];
After (js):
let arg = b();
let arg$1 = a();
let arg$2 = c();
let r = [
arg$1,
arg,
arg$2
];
Review: Why bind every argument that is not stable, not only the moved ones? An argument left in place runs after all bound ones, so it would have to come after them in the source as well. Binding all of them is simpler and only happens for out-of-order calls with effects.
Fixes #9340
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kbf3gHt1hL7PvCPo3r2viL
Signed-off-by: Christoph Knittel <ck@cca.io>
245c6ab to
513572d
Compare
Fixes #9340.
An application lists its arguments in declared order. So a labelled argument passed before arguments declared ahead of it ran after them:
compiled to
[a(), b(), c()], soaran beforeb. This happened for any function and any external, including@obj(mk(~y=b(), ~x=a())). ReScript otherwise evaluates arguments left to right (#9154).Now translcore checks the source positions of the arguments that are not stable. A stable argument reads the same wherever it is evaluated: a constant, variable, function, constant constructor or module path. If the other arguments are out of order and one of them can have side effects, translcore binds them to temporaries in source order. It also binds the callee first, unless the callee is an identifier. The call then gets the temporaries:
These calls compile as before:
Belt.Set.fromArray(~id=module(IntCmp), range(0, 30))mk(~y=o.b, ~x=o.a)Tests:
labelled_argument_order_test.reschecks a function, a@sendand an@objexternal, a callee that is a call, a read after an effect that changes it, an optional argument, a partial application, and arguments already in order.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kbf3gHt1hL7PvCPo3r2viL