Skip to content

Commit bd74e91

Browse files
committed
Remove use of the @res.uapp decorator from the AST.
It used to be required to identify uncurried application. Now all applications are uncurried, so it is redundant.
1 parent cd5ffd3 commit bd74e91

File tree

74 files changed

+666
-1133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+666
-1133
lines changed

jscomp/frontend/ast_attributes.ml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ let process_attributes_rev (attrs : t) : attr_kind * t =
8585
| "this", _ -> Bs_syntaxerr.err loc Conflict_bs_bs_this_bs_meth
8686
| _, _ -> (st, attr :: acc))
8787

88-
let process_bs (attrs : t) =
89-
Ext_list.fold_left attrs (false, [])
90-
(fun (st, acc) (({txt; loc = _}, _) as attr) ->
91-
match (txt, st) with
92-
| "bs", _ -> (true, acc)
93-
| _, _ -> (st, attr :: acc))
94-
9588
let external_attrs =
9689
[|
9790
"get";
@@ -281,10 +274,6 @@ let iter_process_bs_string_or_int_as (attrs : Parsetree.attributes) =
281274
!st
282275

283276
let locg = Location.none
284-
(* let bs : attr
285-
= {txt = "bs" ; loc = locg}, Ast_payload.empty *)
286-
287-
let res_uapp : attr = ({txt = "res.uapp"; loc = locg}, Ast_payload.empty)
288277

289278
let get : attr = ({txt = "get"; loc = locg}, Ast_payload.empty)
290279

jscomp/frontend/ast_attributes.mli

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ type attr_kind = Nothing | Meth_callback of attr | Method of attr
3333

3434
val process_attributes_rev : t -> attr_kind * t
3535

36-
val process_bs : t -> bool * t
37-
3836
val has_inline_payload : t -> attr option
3937

4038
val has_await_payload : t -> attr option
@@ -56,9 +54,6 @@ val iter_process_bs_string_or_int_as : t -> as_const_payload option
5654

5755
val process_derive_type : t -> derive_attr * t
5856

59-
(* Attribute for uncurried application coming from the ReScript parser *)
60-
val res_uapp : attr
61-
6257
val get : attr
6358

6459
val get_index : attr

jscomp/frontend/ast_exp_apply.ml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,14 @@ let infix_ops = ["|."; "|.u"; "#="; "##"]
7373

7474
let app_exp_mapper (e : exp) (self : Bs_ast_mapper.mapper) : exp =
7575
match view_as_app e infix_ops with
76-
| Some {op = ("|." | "|.u") as op; args = [a_; f_]; loc} -> (
76+
| Some {op = "|." | "|.u"; args = [a_; f_]; loc} -> (
7777
(*
7878
a |. f
7979
a |. f b c [@bs] --> f a b c [@bs]
8080
a |. (g |. b)
8181
a |. `Variant
8282
a |. (b |. f c [@bs])
8383
*)
84-
let add_uncurried_attr attrs =
85-
if op = "|.u" && not (List.mem Ast_attributes.res_uapp attrs) then
86-
Ast_attributes.res_uapp :: attrs
87-
else attrs
88-
in
8984
let a = self.expr self a_ in
9085
let f = self.expr self f_ in
9186
match f.pexp_desc with
@@ -98,8 +93,7 @@ let app_exp_mapper (e : exp) (self : Bs_ast_mapper.mapper) : exp =
9893
{
9994
pexp_desc = Pexp_apply (fn1, (Nolabel, a) :: args);
10095
pexp_loc = e.pexp_loc;
101-
pexp_attributes =
102-
add_uncurried_attr (e.pexp_attributes @ f.pexp_attributes);
96+
pexp_attributes = e.pexp_attributes @ f.pexp_attributes;
10397
}
10498
| Pexp_tuple xs ->
10599
bound a (fun bounded_obj_arg ->
@@ -119,18 +113,15 @@ let app_exp_mapper (e : exp) (self : Bs_ast_mapper.mapper) : exp =
119113
{
120114
Parsetree.pexp_desc =
121115
Pexp_apply (fn, (Nolabel, bounded_obj_arg) :: args);
122-
pexp_attributes = add_uncurried_attr [];
116+
pexp_attributes = [];
123117
pexp_loc = fn.pexp_loc;
124118
}
125119
| _ ->
126-
Ast_compatible.app1 ~loc:fn.pexp_loc
127-
~attrs:(add_uncurried_attr []) fn bounded_obj_arg));
120+
Ast_compatible.app1 ~loc:fn.pexp_loc fn bounded_obj_arg));
128121
pexp_attributes = f.pexp_attributes;
129122
pexp_loc = f.pexp_loc;
130123
})
131-
| _ ->
132-
Ast_compatible.app1 ~loc ~attrs:(add_uncurried_attr e.pexp_attributes) f a
133-
)
124+
| _ -> Ast_compatible.app1 ~loc ~attrs:e.pexp_attributes f a)
134125
| Some {op = "##"; loc; args = [obj; rest]} -> (
135126
(* - obj##property
136127
- obj#(method a b )
@@ -173,7 +164,7 @@ let app_exp_mapper (e : exp) (self : Bs_ast_mapper.mapper) : exp =
173164
let arg = self.expr self arg in
174165
let fn = Exp.send ~loc obj {txt = name ^ Literals.setter_suffix; loc} in
175166
Exp.constraint_ ~loc
176-
(Exp.apply ~loc ~attrs:[Ast_attributes.res_uapp] fn [(Nolabel, arg)])
167+
(Exp.apply ~loc fn [(Nolabel, arg)])
177168
(Ast_literal.type_unit ~loc ())
178169
in
179170
match obj.pexp_desc with

jscomp/frontend/bs_ast_invariant.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
*)
2929
let is_bs_attribute txt =
3030
match txt with
31-
| "as" | "bs" | "config" | "ignore" | "int" | "optional" | "string"
32-
| "uncurry" | "unwrap" ->
31+
| "as" | "config" | "ignore" | "int" | "optional" | "string" | "uncurry"
32+
| "unwrap" ->
3333
true
3434
| _ -> false
3535

jscomp/ml/typecore.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,8 +2146,7 @@ and type_expect_ ?type_clash_context ?in_function ?(recarg=Rejected) env sexp ty
21462146
wrap_trace_gadt_instances env (lower_args env []) ty;
21472147
begin_def ();
21482148
let uncurried =
2149-
Ext_list.exists sexp.pexp_attributes (fun ({txt },_) -> txt = "res.uapp")
2150-
&& not @@ Ext_list.exists sexp.pexp_attributes (fun ({txt },_) -> txt = "res.partial")
2149+
not @@ Ext_list.exists sexp.pexp_attributes (fun ({txt },_) -> txt = "res.partial")
21512150
&& not @@ is_automatic_curried_application env funct in
21522151
let type_clash_context = type_clash_context_from_function sexp sfunct in
21532152
let (args, ty_res, fully_applied) = type_application ?type_clash_context uncurried env funct sargs in

jscomp/syntax/src/res_core.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ module InExternal = struct
153153
end
154154

155155
let jsx_attr = (Location.mknoloc "JSX", Parsetree.PStr [])
156-
let uncurried_app_attr = (Location.mknoloc "res.uapp", Parsetree.PStr [])
157156
let ternary_attr = (Location.mknoloc "res.ternary", Parsetree.PStr [])
158157
let if_let_attr = (Location.mknoloc "res.iflet", Parsetree.PStr [])
159158
let optional_attr = (Location.mknoloc "res.optional", Parsetree.PStr [])
@@ -2199,8 +2198,7 @@ and parse_binary_expr ?(context = OrdinaryExpr) ?a p prec =
21992198
match (token, b.pexp_desc) with
22002199
| BarGreater, Pexp_apply (fun_expr, args) ->
22012200
{b with pexp_desc = Pexp_apply (fun_expr, args @ [(Nolabel, a)])}
2202-
| BarGreater, _ ->
2203-
Ast_helper.Exp.apply ~loc ~attrs:[uncurried_app_attr] b [(Nolabel, a)]
2201+
| BarGreater, _ -> Ast_helper.Exp.apply ~loc b [(Nolabel, a)]
22042202
| _ ->
22052203
Ast_helper.Exp.apply ~loc
22062204
(make_infix_operator p token start_pos end_pos)
@@ -3719,8 +3717,7 @@ and parse_call_expr p fun_expr =
37193717
Ext_list.fold_left args fun_expr (fun call_body args ->
37203718
let args, wrap = process_underscore_application args in
37213719
let exp =
3722-
let attrs = [uncurried_app_attr] in
3723-
let attrs = if is_partial then res_partial_attr :: attrs else attrs in
3720+
let attrs = if is_partial then [res_partial_attr] else [] in
37243721
Ast_helper.Exp.apply ~loc ~attrs call_body args
37253722
in
37263723
wrap exp)

jscomp/syntax/src/res_parsetree_viewer.ml

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,6 @@ let functor_type modtype =
4848
in
4949
process [] modtype
5050

51-
let process_uncurried_app_attribute attrs =
52-
let rec process uncurried_app acc attrs =
53-
match attrs with
54-
| [] -> (uncurried_app, List.rev acc)
55-
| ( {
56-
Location.txt =
57-
"bs" (* still support @bs to convert .ml files *) | "res.uapp";
58-
},
59-
_ )
60-
:: rest ->
61-
process true acc rest
62-
| attr :: rest -> process uncurried_app (attr :: acc) rest
63-
in
64-
process false [] attrs
65-
6651
let process_partial_app_attribute attrs =
6752
let rec process partial_app acc attrs =
6853
match attrs with
@@ -210,10 +195,9 @@ let filter_parsing_attrs attrs =
210195
match attr with
211196
| ( {
212197
Location.txt =
213-
( "bs" | "res.uapp" | "res.arity" | "res.braces" | "ns.braces"
214-
| "res.iflet" | "res.namedArgLoc" | "res.optional" | "res.ternary"
215-
| "res.async" | "res.await" | "res.template"
216-
| "res.taggedTemplate" );
198+
( "res.arity" | "res.braces" | "ns.braces" | "res.iflet"
199+
| "res.namedArgLoc" | "res.optional" | "res.ternary" | "res.async"
200+
| "res.await" | "res.template" | "res.taggedTemplate" );
217201
},
218202
_ ) ->
219203
false
@@ -367,9 +351,8 @@ let has_attributes attrs =
367351
match attr with
368352
| ( {
369353
Location.txt =
370-
( "bs" | "res.uapp" | "res.arity" | "res.braces" | "ns.braces"
371-
| "res.iflet" | "res.ternary" | "res.async" | "res.await"
372-
| "res.template" );
354+
( "res.arity" | "res.braces" | "ns.braces" | "res.iflet"
355+
| "res.ternary" | "res.async" | "res.await" | "res.template" );
373356
},
374357
_ ) ->
375358
false
@@ -552,9 +535,8 @@ let is_printable_attribute attr =
552535
match attr with
553536
| ( {
554537
Location.txt =
555-
( "bs" | "res.uapp" | "res.arity" | "res.iflet" | "res.braces"
556-
| "ns.braces" | "JSX" | "res.async" | "res.await" | "res.template"
557-
| "res.ternary" );
538+
( "res.arity" | "res.iflet" | "res.braces" | "ns.braces" | "JSX"
539+
| "res.async" | "res.await" | "res.template" | "res.ternary" );
558540
},
559541
_ ) ->
560542
false

jscomp/syntax/src/res_parsetree_viewer.mli

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ val functor_type :
1414
list
1515
* Parsetree.module_type
1616

17-
val process_uncurried_app_attribute :
18-
Parsetree.attributes -> bool * Parsetree.attributes
19-
2017
val process_partial_app_attribute :
2118
Parsetree.attributes -> bool * Parsetree.attributes
2219

jscomp/syntax/src/res_printer.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4142,9 +4142,7 @@ and print_pexp_apply ~state expr cmt_tbl =
41424142
(fun (lbl, arg) -> (lbl, ParsetreeViewer.rewrite_underscore_apply arg))
41434143
args
41444144
in
4145-
let _, attrs =
4146-
ParsetreeViewer.process_uncurried_app_attribute expr.pexp_attributes
4147-
in
4145+
let attrs = expr.pexp_attributes in
41484146
let partial, attrs = ParsetreeViewer.process_partial_app_attribute attrs in
41494147
let args =
41504148
if partial then

jscomp/syntax/tests/parsing/errors/expressions/expected/array.res.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99
Did you forget a `]` here?
1010

1111
let xs =
12-
((x.map ((Function$ (fun key -> [|key;(predicates.(key))|]))[@res.arity 1]))
13-
[@res.uapp ])
12+
x.map ((Function$ (fun key -> [|key;(predicates.(key))|]))[@res.arity 1])

jscomp/syntax/tests/parsing/errors/expressions/expected/arrow.res.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
Did you forget a `,` here?
1010

11-
;;((((Object.keys providers)[@res.uapp ]).reduce
12-
((Function$
13-
(fun elements ->
14-
fun providerId -> ((let x = 1 in let b = 2 in x + b)
15-
[@res.braces ])))[@res.arity 2]))[@res.uapp ])
11+
;;(Object.keys providers).reduce
12+
((Function$
13+
(fun elements ->
14+
fun providerId -> ((let x = 1 in let b = 2 in x + b)
15+
[@res.braces ])))[@res.arity 2])

jscomp/syntax/tests/parsing/errors/expressions/expected/block.res.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,13 @@ let findThreadByIdLinearScan =
8282
FBID.ofStringUnsafe in
8383
thisId == id)
8484
[@res.braces ])))[@res.arity 2]))
85-
[@res.braces ][@res.uapp ])))
85+
[@res.braces ])))
8686
[@res.arity 2])
87-
let x = ((loop 0 (Nil |.u ((push doc)[@res.uapp ])))
88-
[@res.braces ][@res.uapp ])
87+
let x = ((loop 0 (Nil |.u (push doc)))[@res.braces ])
8988
;;match stack with
9089
| Empty -> [%rescript.exprhole ]
9190
| Cons (doc, rest) -> ()
9291
| Join (doc1, doc2) ->
93-
(buffer |.u ((Buffer.add_string indentation)[@res.uapp ]);
94-
((loop ())
95-
[@res.uapp ]))
92+
(buffer |.u (Buffer.add_string indentation); loop ())
9693
let pipeline =
9794
match scheduler with | Some -> [%rescript.exprhole ] | None -> ()

jscomp/syntax/tests/parsing/errors/expressions/expected/consecutive.res.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,5 @@ let f = ((Function$ (fun a -> fun b -> a + 3))[@res.arity 2])
4848
;;b
4949
let f = ((Function$ (fun g -> fun h -> ((a + 3; b)[@res.braces ])))
5050
[@res.arity 2])
51-
let () = ((((sideEffect1 ())[@res.uapp ]); ((sideEffect2 ())[@res.uapp ]))
52-
[@res.braces ])
53-
let () = ((let open Foo in let exception End in ((x ())[@res.uapp ]))
54-
[@res.braces ])
51+
let () = ((sideEffect1 (); sideEffect2 ())[@res.braces ])
52+
let () = ((let open Foo in let exception End in x ())[@res.braces ])

jscomp/syntax/tests/parsing/errors/expressions/expected/ifLet.res.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ switch result {
3535
| _ => ()
3636
}
3737

38+
;;((match result with | Some x -> Js.log {js|The sky is blue|js} | _ -> ())
39+
[@res.iflet ][@warning "-4"])
3840
;;((match result with
39-
| Some x -> ((Js.log {js|The sky is blue|js})[@res.uapp ])
40-
| _ -> ())[@res.iflet ][@warning "-4"])
41-
;;((match result with
42-
| Error x -> ((Js.log {js|The sky is red|js})[@res.uapp ])
41+
| Error x -> Js.log {js|The sky is red|js}
4342
| _ ->
4443
(((match result with
45-
| Ok y -> ((Js.log {js|The sky is blue|js})[@res.uapp ])
44+
| Ok y -> Js.log {js|The sky is blue|js}
4645
| _ -> ()))
4746
[@res.iflet ][@warning "-4"]))[@res.iflet ][@warning "-4"])

jscomp/syntax/tests/parsing/errors/expressions/expected/letBinding.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
let foo = 2.
8383
let foo = true
8484
let foo = 2
85-
let foo = ((f ())[@res.uapp ])
85+
let foo = f ()
8686
let foo = ((2)[@res.braces ])
8787
let foo = (({js|foo|js})[@res.braces ])
8888
let foo as x = ()

jscomp/syntax/tests/parsing/errors/expressions/expected/record.res.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848

4949
Missing expression
5050

51-
let newWrapper = { updateF; value = ((f xWrapper.currentValue)[@res.uapp ]) }
52-
let newWrapper =
53-
{ updateF; updateF2; value = ((f xWrapper.currentValue)[@res.uapp ]) }
51+
let newWrapper = { updateF; value = (f xWrapper.currentValue) }
52+
let newWrapper = { updateF; updateF2; value = (f xWrapper.currentValue) }
5453
let record = { field = ([%rescript.exprhole ]) }
5554
let record = { field = 2 }

jscomp/syntax/tests/parsing/errors/expressions/expected/setField.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313

1414
;;if match
1515
then let a = 1 in (m.left).compatibleTypeArgs <- ([%rescript.exprhole ])
16-
else ((sideEffect ())[@res.uapp ])
16+
else sideEffect ()

jscomp/syntax/tests/parsing/errors/expressions/expected/try.res.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@
99

1010
Did you forget a `catch` here?
1111

12-
let parsedPayload =
13-
try ((Js.Json.parseExn response)[@res.uapp ]) with | _ -> Js.Json.null
12+
let parsedPayload = try Js.Json.parseExn response with | _ -> Js.Json.null

jscomp/syntax/tests/parsing/errors/other/expected/breadcrumbs170.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
I'm not sure what to parse here when looking at "}".
1212

13-
let l = ((Obj.magic (Some [1; 2; 3]))[@res.uapp ])
13+
let l = Obj.magic (Some [1; 2; 3])
1414
module M = struct ;;match l with | None -> [] | Some l -> l#prop end
1515
;;from
1616
;;now

jscomp/syntax/tests/parsing/errors/pattern/expected/missing.res.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,5 @@
4444
I was expecting a pattern to match on before the `=>`
4545

4646
let 2 = [%rescript.exprhole ]
47-
let 4 =
48-
for [%rescript.patternhole ] = 0 to 10 do
49-
((Js.log {js|for|js})
50-
[@res.uapp ])
51-
done
47+
let 4 = for [%rescript.patternhole ] = 0 to 10 do Js.log {js|for|js} done
5248
;;match x with | () -> [%rescript.exprhole ]

jscomp/syntax/tests/parsing/errors/structure/expected/gh16A.res.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,5 @@
1010

1111
I'm not sure what to parse here when looking at ")".
1212

13-
module C =
14-
struct
15-
module T = (Fun)(struct ;;((foo (a + c) (b + d))[@res.uapp ]) end)
16-
end
17-
;;((Js.log {js|test|js})[@res.uapp ])
13+
module C = struct module T = (Fun)(struct ;;foo (a + c) (b + d) end) end
14+
;;Js.log {js|test|js}

0 commit comments

Comments
 (0)