This repository was archived by the owner on Jun 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +24
-11
lines changed
parsing/grammar/expressions/__snapshots__ Expand file tree Collapse file tree 5 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,8 @@ let normalize =
413413 ]
414414 ) when hasUncurriedAttribute expr.pexp_attributes
415415 ->
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. *)
416418 {expr with
417419 pexp_attributes = mapper.attributes mapper expr.pexp_attributes;
418420 pexp_desc = Pexp_apply (
Original file line number Diff line number Diff line change @@ -3423,12 +3423,12 @@ and parseCallExpr p funExpr =
34233423 pexp_desc = Pexp_construct ({txt = Longident. Lident " ()" }, None );
34243424 pexp_loc = loc;
34253425 pexp_attributes = []
3426- } as expr )
3426+ } as unitExpr )
34273427 ] when (not loc.loc_ghost) && p.mode = ParseForTypeChecker ->
34283428 (* Since there is no syntax space for arity zero vs arity one,
34293429 * we expand
34303430 * `fn(. ())` into
3431- * `fn(. {let __res_unit = (); __res_unit} )`
3431+ * `fn(. ignore() )`
34323432 * when the parsetree is intended for type checking
34333433 *
34343434 * Note:
@@ -3440,12 +3440,12 @@ and parseCallExpr p funExpr =
34403440 [
34413441 true ,
34423442 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+ ]
34493449 ]
34503450 | args -> args
34513451 in
Original file line number Diff line number Diff line change @@ -1599,6 +1599,12 @@ let _ =
15991599 ),
16001600 )
16011601 )
1602+
1603+ let () = {
1604+ resolve (.)
1605+ resolve (.)
1606+ resolve (. ignore ())
1607+ }
16021608"
16031609`;
16041610
Original file line number Diff line number Diff line change @@ -75,3 +75,9 @@ let _ =
7575 ),
7676 )
7777 });
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 ])
1212` ;
1313
1414exports [` 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.
1716let a = ((fun () -> 2)[@bs ])
1817let bar = foo ~a:((a)[@ns.namedArgLoc ])
1918let comparisonResult =
@@ -24,7 +23,7 @@ let comparisonResult =
2423 (elementProps ~onClick:((fun _ -> Js.log \\ "hello world\\ ")
2524 [@ns.namedArgLoc ])))[@bs ])
2625;;((resolve ())[@bs ])
27- ;;((resolve (let __res_unit = () in __res_unit ))[@bs ])"
26+ ;;((resolve (ignore () ))[@bs ])"
2827` ;
2928
3029exports [` array.js 1` ] = `
You can’t perform that action at this time.
0 commit comments