Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

- Fix issue with GenType and `result` introduced in rc.5. https://github.com/rescript-lang/rescript-compiler/pull/6464
- Fix compiler crash when inlining complex constants in pattern matching. https://github.com/rescript-lang/rescript-compiler/pull/6471
- Fix issue with generating async functions inside loops. https://github.com/rescript-lang/rescript-compiler/pull/6479


# 11.0.0-rc.5

Expand Down
3 changes: 2 additions & 1 deletion jscomp/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,13 @@ and pp_function ~return_unit ~async ~is_method cxt (f : P.t) ~fn_state
| No_name _ -> ()
| Name_non_top name | Name_top name ->
ignore (pp_var_assign inner_cxt f name : cxt));
if async then P.string f L.await;
P.string f L.lparen;
P.string f (L.function_async ~async);
pp_paren_params inner_cxt f lexical;
P.brace_vgroup f 0 (fun _ ->
return_sp f;
P.string f L.function_;
P.string f (L.function_async ~async);
P.space f;
(match fn_state with
| Is_return | No_name _ -> ()
Expand Down
3 changes: 3 additions & 0 deletions jscomp/core/js_dump_lit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)


let await = "await"

let function_ = "function"

let function_async ~async = if async then "async function" else "function"
Expand Down
20 changes: 20 additions & 0 deletions jscomp/test/async_inside_loop.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions jscomp/test/async_inside_loop.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
let topLevelAsyncFunction = async () => {
for innerScopeVal in 0 to 3 {
let asyncClosureAccessingScopedVal = async () => {
Js.log2("Accessing scoped var inside loop", innerScopeVal)
await Js.Promise.resolve()
}

await asyncClosureAccessingScopedVal()
}
}

let _ = topLevelAsyncFunction()
3 changes: 2 additions & 1 deletion jscomp/test/build.ninja

Large diffs are not rendered by default.