-
Notifications
You must be signed in to change notification settings - Fork 484
Fix argument evaluation order under function inlining #8572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Generated by ReScript, PLEASE EDIT WITH CARE | ||
|
|
||
| import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; | ||
|
|
||
| let recorded = []; | ||
|
|
||
| let equalish = Primitive_object.equal; | ||
|
|
||
| function copy(a) { | ||
| return a.slice(); | ||
| } | ||
|
|
||
| function helper(x, y) { | ||
| return Primitive_object.equal(x, y.slice()); | ||
| } | ||
|
|
||
| function effA(_n) { | ||
| while (true) { | ||
| let n = _n; | ||
| recorded.push("a"); | ||
| if (n <= 0) { | ||
| return [n]; | ||
| } | ||
| _n = n - 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
|
|
||
| function effB(_n) { | ||
| while (true) { | ||
| let n = _n; | ||
| recorded.push("b"); | ||
| if (n <= 0) { | ||
| return [n]; | ||
| } | ||
| _n = n - 1 | 0; | ||
| continue; | ||
| }; | ||
| } | ||
|
|
||
| let x = effA(0); | ||
|
|
||
| let y = effB(0); | ||
|
|
||
| Primitive_object.equal(x, y.slice()); | ||
|
|
||
| export { | ||
| recorded, | ||
| equalish, | ||
| copy, | ||
| helper, | ||
| effA, | ||
| effB, | ||
| } | ||
| /* x Not a pure module */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // The beta reducer used to stack inlined-call argument bindings in reverse | ||
| // parameter order, so the last argument was evaluated first. The checked-in | ||
| // JS pins evaluation to source order: effA runs before effB. | ||
| let recorded: array<string> = [] | ||
|
|
||
| let equalish = (a: array<int>, b: array<int>) => a == b | ||
| let copy = (a: array<int>) => Array.copy(a) | ||
| let helper = (x, y) => equalish(x, copy(y)) | ||
|
|
||
| let rec effA = n => { | ||
| recorded->Array.push("a") | ||
| if n > 0 { | ||
| effA(n - 1) | ||
| } else { | ||
| [n] | ||
| } | ||
| } | ||
|
|
||
| let rec effB = n => { | ||
| recorded->Array.push("b") | ||
| if n > 0 { | ||
| effB(n - 1) | ||
| } else { | ||
| [n] | ||
| } | ||
| } | ||
|
|
||
| let _ = { | ||
| helper(effA(0), effB(0)) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixture evaluates the call for
effA/effBside effects and intentionally discards its Boolean result, solet _ = ...is precisely the side-effect-only wildcard-binding pattern prohibited by the repository guidance. Useignore(helper(effA(0), effB(0)))(or the equivalent pipeline form) so the intent is explicit without relying on a wildcard binding.AGENTS.md reference: AGENTS.md:L43-L44
Useful? React with 👍 / 👎.