This repository was archived by the owner on Jun 15, 2023. It is now read-only.
File tree 5 files changed +24
-11
lines changed
parsing/grammar/expressions/__snapshots__ 5 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,8 @@ let normalize =
413
413
]
414
414
) when hasUncurriedAttribute expr.pexp_attributes
415
415
->
416
+ (* In Reason both f(.) and f(. ()) express arity0. In ReScript only f(.)
417
+ * expresses arity0. We tweak the Reason version to always match the f(.) on the Reason side. *)
416
418
{expr with
417
419
pexp_attributes = mapper.attributes mapper expr.pexp_attributes;
418
420
pexp_desc = Pexp_apply (
Original file line number Diff line number Diff line change @@ -3423,12 +3423,12 @@ and parseCallExpr p funExpr =
3423
3423
pexp_desc = Pexp_construct ({txt = Longident. Lident " ()" }, None );
3424
3424
pexp_loc = loc;
3425
3425
pexp_attributes = []
3426
- } as expr )
3426
+ } as unitExpr )
3427
3427
] when (not loc.loc_ghost) && p.mode = ParseForTypeChecker ->
3428
3428
(* Since there is no syntax space for arity zero vs arity one,
3429
3429
* we expand
3430
3430
* `fn(. ())` into
3431
- * `fn(. {let __res_unit = (); __res_unit} )`
3431
+ * `fn(. ignore() )`
3432
3432
* when the parsetree is intended for type checking
3433
3433
*
3434
3434
* Note:
@@ -3440,12 +3440,12 @@ and parseCallExpr p funExpr =
3440
3440
[
3441
3441
true ,
3442
3442
Asttypes. Nolabel ,
3443
- Ast_helper.Exp. let_
3444
- Asttypes. Nonrecursive
3445
- [ Ast_helper.Vb. mk
3446
- ( Ast_helper.Pat. var ( Location. mknoloc " __res_unit " ))
3447
- expr]
3448
- ( Ast_helper.Exp. ident ( Location. mknoloc ( Longident. Lident " __res_unit " )))
3443
+ Ast_helper.Exp. apply
3444
+ ( Ast_helper.Exp. ident ( Location. mknoloc ( Longident. Lident " ignore " )))
3445
+ [
3446
+ Asttypes. Nolabel ,
3447
+ unitExpr
3448
+ ]
3449
3449
]
3450
3450
| args -> args
3451
3451
in
Original file line number Diff line number Diff line change @@ -1599,6 +1599,12 @@ let _ =
1599
1599
),
1600
1600
)
1601
1601
)
1602
+
1603
+ let () = {
1604
+ resolve (.)
1605
+ resolve (.)
1606
+ resolve (. ignore ())
1607
+ }
1602
1608
"
1603
1609
`;
1604
1610
Original file line number Diff line number Diff line change @@ -75,3 +75,9 @@ let _ =
75
75
),
76
76
)
77
77
});
78
+
79
+ let () = {
80
+ resolve(.)
81
+ resolve(. () )
82
+ resolve(. ignore () )
83
+ }
Original file line number Diff line number Diff line change @@ -12,8 +12,7 @@ let unitUncurried = ((apply ())[@bs ])
12
12
` ;
13
13
14
14
exports [` argument.js 1` ] = `
15
- "let foo ~a:((a)[@ns.namedArgLoc ]) =
16
- ((a (let __res_unit = () in __res_unit))[@bs ]) +. 1.
15
+ "let foo ~a:((a)[@ns.namedArgLoc ]) = ((a (ignore ()))[@bs ]) +. 1.
17
16
let a = ((fun () -> 2)[@bs ])
18
17
let bar = foo ~a:((a)[@ns.namedArgLoc ])
19
18
let comparisonResult =
@@ -24,7 +23,7 @@ let comparisonResult =
24
23
(elementProps ~onClick:((fun _ -> Js.log \\ "hello world\\ ")
25
24
[@ns.namedArgLoc ])))[@bs ])
26
25
;;((resolve ())[@bs ])
27
- ;;((resolve (let __res_unit = () in __res_unit ))[@bs ])"
26
+ ;;((resolve (ignore () ))[@bs ])"
28
27
` ;
29
28
30
29
exports [` array.js 1` ] = `
You can’t perform that action at this time.
0 commit comments