diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c6ebb9b13..257a5f0cce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: runs-on: ${{matrix.os}} container: - image: ghcr.io/rescript-lang/rescript-ci-build:v1.1.0 + image: ghcr.io/rescript-lang/rescript-ci-build:v1.2.0 steps: # See https://github.com/actions/runner/issues/801#issuecomment-1374967227. @@ -115,7 +115,7 @@ jobs: ubuntu-latest, windows-latest, ] - ocaml_compiler: [4.14.0] + ocaml_compiler: [4.14.1] runs-on: ${{matrix.os}} @@ -147,7 +147,7 @@ jobs: chmod +x _build/install/default/bin/* - name: Use OCaml ${{matrix.ocaml_compiler}} - uses: ocaml/setup-ocaml@v2.1.7 + uses: ocaml/setup-ocaml@v2 if: matrix.os != 'windows-latest' with: ocaml-compiler: ${{matrix.ocaml_compiler}} @@ -155,7 +155,7 @@ jobs: opam-depext: false - name: Use OCaml ${{matrix.ocaml_compiler}} (Win) - uses: ocaml/setup-ocaml@v2.1.7 + uses: ocaml/setup-ocaml@v2 if: matrix.os == 'windows-latest' with: ocaml-compiler: ${{matrix.ocaml_compiler}} diff --git a/CHANGELOG.md b/CHANGELOG.md index a5b8b25b4f..86b73e7b2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,14 @@ # 12.0.0-alpha.1 (Unreleased) +#### :bug: Bug Fix + +- Fix issue with async and newtype in uncurried mode. https://github.com/rescript-lang/rescript-compiler/pull/6601 + +#### :house: Internal + +- Use OCaml 4.14.1 (+ Alpine 3.19 container) for CI build. https://github.com/rescript-lang/rescript-compiler/pull/6600 + # 11.1.0-rc.1 #### :rocket: New Feature diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 56a9d7391a..dda45b2ba1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,7 +41,7 @@ Make sure you have [opam](https://opam.ocaml.org/doc/Install.html) installed on opam init # Any recent OCaml version works as a development compiler -opam switch create 4.14.0 # can also create local switch with opam switch create . 4.14.0 +opam switch create 4.14.1 # can also create local switch with opam switch create . 4.14.1 # Install dev dependencies from OPAM opam install . --deps-only diff --git a/jscomp/ml/ast_async.ml b/jscomp/ml/ast_async.ml index d16b193a4c..b1552cd9a2 100644 --- a/jscomp/ml/ast_async.ml +++ b/jscomp/ml/ast_async.ml @@ -13,12 +13,18 @@ let add_promise_type ?(loc = Location.none) ~async let add_async_attribute ~async (body : Parsetree.expression) = if async then - { - body with - pexp_attributes = - ({txt = "res.async"; loc = Location.none}, PStr []) - :: body.pexp_attributes; - } + ( + match body.pexp_desc with + | Pexp_construct (x, Some e) when Ast_uncurried.exprIsUncurriedFun body -> + {body with pexp_desc = Pexp_construct (x, Some {e with pexp_attributes = + ({txt = "res.async"; loc = Location.none}, PStr []) :: e.pexp_attributes} )} + | _ -> + { + body with + pexp_attributes = + ({txt = "res.async"; loc = Location.none}, PStr []) + :: body.pexp_attributes; + }) else body let rec add_promise_to_result ~loc (e : Parsetree.expression) = diff --git a/jscomp/test/async_await.js b/jscomp/test/async_await.js index 0c674d3b90..d376f50acf 100644 --- a/jscomp/test/async_await.js +++ b/jscomp/test/async_await.js @@ -34,6 +34,10 @@ var toplevelAwait = await topFoo(); var toplevelAwait2 = Caml_array.get(arr, await topFoo()); +async function f(value) { + return await Promise.resolve(1); +} + exports.next = next; exports.useNext = useNext; exports.Make = Make; @@ -41,4 +45,5 @@ exports.topFoo = topFoo; exports.arr = arr; exports.toplevelAwait = toplevelAwait; exports.toplevelAwait2 = toplevelAwait2; +exports.f = f; /* toplevelAwait Not a pure module */ diff --git a/jscomp/test/async_await.res b/jscomp/test/async_await.res index fd7bf92f34..85aafb08bd 100644 --- a/jscomp/test/async_await.res +++ b/jscomp/test/async_await.res @@ -16,3 +16,7 @@ let arr = [1, 2, 3] let toplevelAwait = await topFoo() let toplevelAwait2 = arr[await topFoo()] + +let f = async (type input, value: input) => { + await Js.Promise.resolve(. 1) +} \ No newline at end of file