File tree 10 files changed +87
-5
lines changed
10 files changed +87
-5
lines changed Original file line number Diff line number Diff line change 15
15
#### :bug : Bug Fix
16
16
- Fix implementation of directives https://github.com/rescript-lang/rescript-compiler/pull/6052
17
17
18
+ #### :rocket : New Feature
19
+ - Add support for toplevel ` await ` https://github.com/rescript-lang/rescript-compiler/pull/6054
20
+
18
21
# 10.1.3
19
22
20
23
#### :rocket : New Feature
Original file line number Diff line number Diff line change
1
+
2
+ [1;31mWe've found a bug for you![0m
3
+ [36m/.../fixtures/await.res[0m:[2m4:9-17[0m
4
+
5
+ 2 [2m│[0m let foo = async () => {
6
+ 3 [2m│[0m let _ = ()
7
+ [1;31m4[0m [2m│[0m () => [1;31mawait a()[0m
8
+ 5 [2m│[0m }
9
+ 6 [2m│[0m
10
+
11
+ Await on expression not in an async context
Original file line number Diff line number Diff line change
1
+ let a = async () => 3
2
+ let foo = async () => {
3
+ let _ = ()
4
+ () => await a ()
5
+ }
Original file line number Diff line number Diff line change @@ -551,7 +551,7 @@ let rec structure_mapper (self : mapper) (stru : Ast_structure.t) =
551
551
let mapper : mapper =
552
552
{
553
553
default_mapper with
554
- expr = expr_mapper ~async_context: (ref false ) ~in_function_def: (ref false );
554
+ expr = expr_mapper ~async_context: (ref true ) ~in_function_def: (ref false );
555
555
pat = pat_mapper;
556
556
typ = typ_mapper;
557
557
class_type = class_type_mapper;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ var Curry = require ( "../../lib/js/curry.js" ) ;
4
+ var Caml_array = require ( "../../lib/js/caml_array.js" ) ;
5
+
6
+ function next ( n ) {
7
+ return n + 1 | 0 ;
8
+ }
9
+
10
+ async function useNext ( param ) {
11
+ return 4 ;
12
+ }
13
+
14
+ function Make ( I ) {
15
+ var get = async function ( key ) {
16
+ return await Curry . _1 ( I . get , key ) ;
17
+ } ;
18
+ return {
19
+ get : get
20
+ } ;
21
+ }
22
+
23
+ async function topFoo ( param ) {
24
+ return 1 ;
25
+ }
26
+
27
+ var arr = [
28
+ 1 ,
29
+ 2 ,
30
+ 3
31
+ ] ;
32
+
33
+ var toplevelAwait = await topFoo ( undefined ) ;
34
+
35
+ var toplevelAwait2 = Caml_array . get ( arr , await topFoo ( undefined ) ) ;
36
+
37
+ exports . next = next ;
38
+ exports . useNext = useNext ;
39
+ exports . Make = Make ;
40
+ exports . topFoo = topFoo ;
41
+ exports . arr = arr ;
42
+ exports . toplevelAwait = toplevelAwait ;
43
+ exports . toplevelAwait2 = toplevelAwait2 ;
44
+ /* toplevelAwait Not a pure module */
Original file line number Diff line number Diff line change
1
+ @@uncurried
2
+
3
+ let next = n => n + 1
4
+ let useNext = async () => next (3 )
5
+
6
+ module type Impl = {
7
+ let get : string => Js .Promise .t <string >
8
+ }
9
+
10
+ module Make = (I : Impl ) => {
11
+ let get = async (key ) => await I .get (key )
12
+ }
13
+
14
+ let topFoo = async () => 1
15
+ let arr = [1 , 2 , 3 ]
16
+
17
+ let toplevelAwait = await topFoo ()
18
+ let toplevelAwait2 = arr [await topFoo ()]
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -273452,7 +273452,7 @@ let rec structure_mapper (self : mapper) (stru : Ast_structure.t) =
273452
273452
let mapper : mapper =
273453
273453
{
273454
273454
default_mapper with
273455
- expr = expr_mapper ~async_context:(ref false ) ~in_function_def:(ref false);
273455
+ expr = expr_mapper ~async_context:(ref true ) ~in_function_def:(ref false);
273456
273456
pat = pat_mapper;
273457
273457
typ = typ_mapper;
273458
273458
class_type = class_type_mapper;
Original file line number Diff line number Diff line change @@ -273452,7 +273452,7 @@ let rec structure_mapper (self : mapper) (stru : Ast_structure.t) =
273452
273452
let mapper : mapper =
273453
273453
{
273454
273454
default_mapper with
273455
- expr = expr_mapper ~async_context:(ref false ) ~in_function_def:(ref false);
273455
+ expr = expr_mapper ~async_context:(ref true ) ~in_function_def:(ref false);
273456
273456
pat = pat_mapper;
273457
273457
typ = typ_mapper;
273458
273458
class_type = class_type_mapper;
Original file line number Diff line number Diff line change @@ -283849,7 +283849,7 @@ let rec structure_mapper (self : mapper) (stru : Ast_structure.t) =
283849
283849
let mapper : mapper =
283850
283850
{
283851
283851
default_mapper with
283852
- expr = expr_mapper ~async_context:(ref false ) ~in_function_def:(ref false);
283852
+ expr = expr_mapper ~async_context:(ref true ) ~in_function_def:(ref false);
283853
283853
pat = pat_mapper;
283854
283854
typ = typ_mapper;
283855
283855
class_type = class_type_mapper;
You can’t perform that action at this time.
0 commit comments