| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
rescript
npm i https://pkg.pr.new/rescript@7887
npm i https://pkg.pr.new/@rescript/darwin-arm64@7887
npm i https://pkg.pr.new/@rescript/darwin-x64@7887
npm i https://pkg.pr.new/@rescript/linux-arm64@7887
npm i https://pkg.pr.new/@rescript/linux-x64@7887
npm i https://pkg.pr.new/@rescript/runtime@7887
npm i https://pkg.pr.new/@rescript/win32-x64@7887 commit: ee5708e |
Sorry, something went wrong.
|
The big questions were language design related ones, rather than implementation. |
Sorry, something went wrong.
|
Frankly, importing the JavaScript for-of syntax as-is doesn't sound all that appealing. It's not much different from embedding %raw. Here are my thoughts on designing for loops:
|
Sorry, something went wrong.
https://github.com/JonoPrest/iterator-rescript/blob/retreat-note/RETREAT_NOTE.md On the last retreat, we only discussed iterator semantics and simulating break/continue; we also need to deal with the early-return or jump (for escaping nested loops) semantics. |
Sorry, something went wrong.
|
Early return keeps on coming up as a topic. |
Sorry, something went wrong.
|
For me, the for..of feature as implemented here would already be useful in and of itself because it
let asyncProcess = async () => {
let results = []
for item of arr {
let result = await processData(item)
results->Array.push(result)
}
results
}
for item for arr {
# vs.
arr->Array.forEach(item =>
I agree that early return would be nice to have, but not sure if we should tie this to for..of. I also agree that it would be a good idea to look into how iterators should work. |
Sorry, something went wrong.
This is already a dangerous assumption. for-of loops are all about iterators, not arrays. It should be designed to interact with iterator types. When it works with array types, it leads users to copy arbitrary iterators into arrays unnecessarily. |
Sorry, something went wrong.
There was a problem hiding this comment.
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a96c795ce
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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".
Sorry, something went wrong.
Done! 😄 |
Sorry, something went wrong.
There was a problem hiding this comment.
Here are some automated review suggestions for this pull request.
Reviewed commit: 4389e9c1c4
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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".
Sorry, something went wrong.
| | Int_switch _ | String_switch _ | ForRange _ | ForOf _ | ForAwaitOf _ | ||
| | If _ | While _ | Block _ | Return _ | Try _ -> |
There was a problem hiding this comment.
Treat iterator loops as side-effecting in JS analyzer
no_side_effect_obj.statement now classifies ForOf and ForAwaitOf via structural traversal, so loops with a pure-looking iterable expression/body are considered removable. Unlike ForRange, these loops invoke iterator protocol methods (Symbol.iterator/next or async variants), which can execute arbitrary user code even when the iterable is just an identifier; this feeds into js_shake's statement pruning and can incorrectly drop runtime-visible effects.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
| | Texp_for_of (_id, _pat, e1, e2) -> | ||
| e1 |> exprNoSideEffects && e2 |> exprNoSideEffects | ||
| | Texp_for_await_of (_id, _pat, e1, e2) -> | ||
| e1 |> exprNoSideEffects && e2 |> exprNoSideEffects |
There was a problem hiding this comment.
Mark iterator loops effectful in reanalyze side-effects
exprNoSideEffects now returns true for Texp_for_of/Texp_for_await_of when only the loop expression/body look pure, but iteration itself can run effectful iterator callbacks on custom iterables. Since SideEffects.checkExpr is used to set declaration side-effect metadata in dead-value reporting, this can misclassify effectful values as effect-free and produce incorrect dead-code diagnostics.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
This PR adds native for...of and for await...of loop support to ReScript across the full compiler pipeline.
It introduces parser, AST, typedtree, lambda IR, and JS backend support for both loop forms, preserves break / continue semantics inside nested control-flow, and adds syntax, type-error, analysis, and end-to-end test coverage for the new feature.
What changed
Coverage