Skip to content

Commit 6e77af7

Browse files
committed
Remove @res.partial entirely.
1 parent 7abe581 commit 6e77af7

20 files changed

+86
-86
lines changed

compiler/ml/ast_mapper_from0.ml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,18 @@ module E = struct
310310
(sub.pat sub p) (sub.expr sub e)
311311
| Pexp_function _ -> assert false
312312
| Pexp_apply (e, l) ->
313-
apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l)
313+
let process_partial_app_attribute attrs =
314+
let rec process partial_app acc attrs =
315+
match attrs with
316+
| [] -> (partial_app, List.rev acc)
317+
| ({Location.txt = "res.partial"}, _) :: rest -> process true acc rest
318+
| attr :: rest -> process partial_app (attr :: acc) rest
319+
in
320+
process false [] attrs
321+
in
322+
let partial, attrs = process_partial_app_attribute attrs in
323+
apply ~loc ~attrs ~partial (sub.expr sub e)
324+
(List.map (map_snd (sub.expr sub)) l)
314325
| Pexp_match (e, pel) ->
315326
match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel)
316327
| Pexp_try (e, pel) -> try_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel)

compiler/ml/ast_mapper_to0.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,11 @@ module E = struct
325325
~attrs:(arity_to_attributes arity)
326326
(Location.mkloc (Longident.Lident "Function$") e.pexp_loc)
327327
(Some e))
328-
| Pexp_apply {funct = e; args = l} ->
328+
| Pexp_apply {funct = e; args = l; partial} ->
329+
let attrs =
330+
if partial then (Location.mknoloc "res.partial", Pt.PStr []) :: attrs
331+
else []
332+
in
329333
apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l)
330334
| Pexp_match (e, pel) ->
331335
match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel)

compiler/syntax/src/res_core.ml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3719,14 +3719,7 @@ and parse_call_expr p fun_expr =
37193719
let apply =
37203720
Ext_list.fold_left args fun_expr (fun call_body args ->
37213721
let args, wrap = process_underscore_application args in
3722-
let res_partial_attr =
3723-
let loc = mk_loc start_pos p.prev_end_pos in
3724-
(Location.mkloc "res.partial" loc, Parsetree.PStr [])
3725-
in
3726-
let exp =
3727-
let attrs = if partial then [res_partial_attr] else [] in
3728-
Ast_helper.Exp.apply ~loc ~attrs ~partial call_body args
3729-
in
3722+
let exp = Ast_helper.Exp.apply ~loc ~partial call_body args in
37303723
wrap exp)
37313724
in
37323725

compiler/syntax/src/res_parsetree_viewer.ml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@ let functor_type modtype =
7070
in
7171
process [] modtype
7272

73-
let process_partial_app_attribute attrs =
74-
let rec process partial_app acc attrs =
75-
match attrs with
76-
| [] -> (partial_app, List.rev acc)
77-
| ({Location.txt = "res.partial"}, _) :: rest -> process true acc rest
78-
| attr :: rest -> process partial_app (attr :: acc) rest
79-
in
80-
process false [] attrs
81-
8273
let has_await_attribute attrs =
8374
List.exists
8475
(function

compiler/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_partial_app_attribute :
18-
Parsetree.attributes -> bool * Parsetree.attributes
19-
2017
val has_await_attribute : Parsetree.attributes -> bool
2118
val has_res_pat_variant_spread_attribute : Parsetree.attributes -> bool
2219
val has_dict_pattern_attribute : Parsetree.attributes -> bool

compiler/syntax/src/res_printer.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4271,7 +4271,6 @@ and print_pexp_apply ~state expr cmt_tbl =
42714271
args
42724272
in
42734273
let attrs = expr.pexp_attributes in
4274-
let _, attrs = ParsetreeViewer.process_partial_app_attribute attrs in
42754274
let args =
42764275
if partial then
42774276
let dummy = Ast_helper.Exp.constant ~attrs (Ast_helper.Const.int 0) in

tests/syntax_tests/data/parsing/grammar/expressions/expected/apply.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
;;List.reduce (fun [arity:2]acc -> fun curr -> acc + curr) 0 myList
77
let unitUncurried = apply ()
88
;;call ~a:(((((a)[@res.namedArgLoc ]) : int))[@res.namedArgLoc ])
9-
;;((call_partial 3 ...)[@res.partial ])
9+
;;call_partial 3 ...

tests/syntax_tests/data/printer/expr/expected/UncurriedByDefault.res.txt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@ let fn = (
170170
provikingMultilineFormattingaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
171171
}
172172

173-
let partial =
174-
fn(
175-
~hello=1,
176-
~moreGoesHere=1,
177-
~provikingMultilineFormattingaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=1,
178-
...
179-
)
173+
let partial = fn(
174+
~hello=1,
175+
~moreGoesHere=1,
176+
~provikingMultilineFormattingaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=1,
177+
...
178+
)

tests/syntax_tests/data/printer/expr/expected/apply.res.txt

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -100,40 +100,34 @@ let g = f(
100100
c,
101101
)
102102

103-
let g =
104-
f(
105-
a =>
106-
LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(a),
107-
b,
108-
c,
109-
...
110-
)
111-
112-
let g =
113-
f(
114-
a =>
115-
LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(a),
116-
b,
117-
c =>
118-
LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(
119-
d,
120-
...
121-
),
122-
...
123-
)
124-
125-
let g =
126-
f(
127-
a =>
128-
LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(
129-
a,
130-
...
131-
),
132-
b,
133-
c =>
134-
LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(d),
135-
...
136-
)
103+
let g = f(
104+
a => LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(a),
105+
b,
106+
c,
107+
...
108+
)
109+
110+
let g = f(
111+
a => LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(a),
112+
b,
113+
c =>
114+
LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(
115+
d,
116+
...
117+
),
118+
...
119+
)
120+
121+
let g = f(
122+
a =>
123+
LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(
124+
a,
125+
...
126+
),
127+
b,
128+
c => LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(d),
129+
...
130+
)
137131

138132
let g = f(
139133
a => LongModuleName.functionWithAlongNameThatWrapsTheEditorToTheNextLinexxxxxxxxxxxxxxxxxxxxxx(a),

tests/tests/src/arity_deopt.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ function f3(x) {
4141
return (y, z) => (x + y | 0) + z | 0;
4242
}
4343

44-
eq("File \"arity_deopt.res\", line 50, characters 6-13", 6, 6);
44+
eq("File \"arity_deopt.res\", line 50, characters 5-12", 6, 6);
4545

46-
eq("File \"arity_deopt.res\", line 51, characters 6-13", 6, 6);
46+
eq("File \"arity_deopt.res\", line 51, characters 5-12", 6, 6);
4747

48-
eq("File \"arity_deopt.res\", line 52, characters 6-13", 6, 6);
48+
eq("File \"arity_deopt.res\", line 52, characters 5-12", 6, 6);
4949

50-
eq("File \"arity_deopt.res\", line 53, characters 6-13", 6, 6);
50+
eq("File \"arity_deopt.res\", line 53, characters 5-12", 6, 6);
5151

5252
Mt.from_pair_suites("Arity_deopt", suites.contents);
5353

0 commit comments

Comments
 (0)