Skip to content

Commit e0dcab6

Browse files
committed
Remove @res.partial entirely.
1 parent ba77b7f commit e0dcab6

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

tests/tests/src/arity_deopt.res

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ let f3 = x => {
4747
So the best is never shrink functons which could change arity
4848
*/
4949
let () = {
50-
(eq(__LOC__, 6, ...))(f0(1, 2, 3))
51-
(eq(__LOC__, 6, ...))(f1(1)(2, 3))
52-
(eq(__LOC__, 6, ...))(f2(1, 2)(3))
53-
(eq(__LOC__, 6, ...))(f3(1)(2, 3))
50+
eq(__LOC__, 6, ...)(f0(1, 2, 3))
51+
eq(__LOC__, 6, ...)(f1(1)(2, 3))
52+
eq(__LOC__, 6, ...)(f2(1, 2)(3))
53+
eq(__LOC__, 6, ...)(f3(1)(2, 3))
5454
}
5555
let () = Mt.from_pair_suites(__MODULE__, suites.contents)

tests/tests/src/bs_mutable_set_test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ for (let i$2 = 0; i$2 <= 100000; ++i$2) {
284284

285285
Belt_MutableSetInt.checkInvariantInternal(v$1);
286286

287-
b("File \"bs_mutable_set_test.res\", line 168, characters 5-12", Belt_Range.every(0, 100000, i => Belt_MutableSetInt.has(v$1, i)));
287+
b("File \"bs_mutable_set_test.res\", line 168, characters 4-11", Belt_Range.every(0, 100000, i => Belt_MutableSetInt.has(v$1, i)));
288288

289289
eq("File \"bs_mutable_set_test.res\", line 169, characters 5-12", Belt_MutableSetInt.size(v$1), 100001);
290290

tests/tests/src/bs_mutable_set_test.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ let () = {
165165
N.add(v, i)
166166
}
167167
N.checkInvariantInternal(v)
168-
(b(__LOC__, ...))(R.every(0, 1_00_000, i => N.has(v, i)))
168+
b(__LOC__, ...)(R.every(0, 1_00_000, i => N.has(v, i)))
169169
eq(__LOC__, N.size(v), 1_00_001)
170170
}
171171

tests/tests/src/gpr_2614_test.res

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ external a : ?low:int -> hi:int -> a
3636
low: a -> int option [@@return undefined_to_opt]
3737
lowSet : a -> int -> unit
3838
*/
39-
let h0 =
40-
a(~hi=2, ~low="x", ...)
39+
let h0 = a(~hi=2, ~low="x", ...)
4140

4241
let h1 = a(~hi=2, ~low="x", ())
4342

tests/tests/src/map_find_test.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ include (
1919
) => acc->SMap.set(k, v))
2020
@val("console.log") external log: 'a => unit = ""
2121

22-
(Mt.from_pair_suites(__MODULE__, ...))(list{
22+
Mt.from_pair_suites(__MODULE__, ...)(list{
2323
("int", _ => Eq(IntMap.get(m, 10), Some('a'))),
2424
("string", _ => Eq(SMap.get(s, "10"), Some('a'))),
2525
})

tests/tests/src/option_repr_test.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ let xs = {
175175
tl: /* [] */0
176176
};
177177

178-
b("File \"option_repr_test.res\", line 125, characters 3-10", Belt_List.every(xs, x => x));
178+
b("File \"option_repr_test.res\", line 125, characters 2-9", Belt_List.every(xs, x => x));
179179

180180
let xs_0$1 = Primitive_object.lessthan(Primitive_option.some(undefined), 3) && Primitive_object.greaterthan(3, Primitive_option.some(undefined));
181181

@@ -216,7 +216,7 @@ let xs$1 = {
216216
tl: xs_1
217217
};
218218

219-
b("File \"option_repr_test.res\", line 127, characters 3-10", Belt_List.every(xs$1, x => x));
219+
b("File \"option_repr_test.res\", line 127, characters 2-9", Belt_List.every(xs$1, x => x));
220220

221221
let xs_1$1 = {
222222
hd: neqx(undefined, null),
@@ -237,7 +237,7 @@ let xs$2 = {
237237
tl: xs_1$1
238238
};
239239

240-
b("File \"option_repr_test.res\", line 143, characters 3-10", Belt_List.every(xs$2, x => x));
240+
b("File \"option_repr_test.res\", line 143, characters 2-9", Belt_List.every(xs$2, x => x));
241241

242242
function v(x) {
243243
return x;

tests/tests/src/option_repr_test.res

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ let neqx = (a, b) => a != b && b != a
122122

123123
let all_true = xs => Belt.List.every(xs, x => x)
124124

125-
(b(__LOC__, ...))(all_true(list{gtx(Some(Some(Js.null)), Some(None))}))
125+
b(__LOC__, ...)(all_true(list{gtx(Some(Some(Js.null)), Some(None))}))
126126

127-
(b(__LOC__, ...))(
127+
b(__LOC__, ...)(
128128
all_true(list{
129129
ltx(Some(None), Some(Some(3))),
130130
ltx(Some(None), Some(Some(None))),
@@ -140,7 +140,7 @@ let all_true = xs => Belt.List.every(xs, x => x)
140140
}),
141141
)
142142

143-
(b(__LOC__, ...))(
143+
b(__LOC__, ...)(
144144
all_true(list{
145145
eqx(None, None),
146146
neqx(None, Some(Js.null)),

tests/tests/src/test_string_map.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ include (
1313
let assertion_test = () => {
1414
let m = ref(StringMap.empty)
1515
let count = 1000000
16-
(timing("building", ...))(_ =>
16+
timing("building", ...)(_ =>
1717
for i in 0 to count {
1818
m := m.contents->StringMap.set(Js.Int.toString(i), Js.Int.toString(i))
1919
}
2020
)
21-
(timing("querying", ...))(_ =>
21+
timing("querying", ...)(_ =>
2222
for i in 0 to count {
2323
m.contents->StringMap.get(Js.Int.toString(i))->ignore
2424
}

tests/tools_tests/ppx/TestPpx.res

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ let async_foo = async (x, y) => {
4242
let b: promise<int> = async_succ(y)
4343
(await a) + (await b)
4444
}
45+
46+
let add = (x, y) => x + y
47+
let partial_add = add(3, ...)

tests/tools_tests/src/expected/TestPpx.res.jsout

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ async function async_foo(x, y) {
5151
return await a + await b | 0;
5252
}
5353

54+
function add(x, y) {
55+
return x + y | 0;
56+
}
57+
58+
function partial_add(extra) {
59+
return 3 + extra | 0;
60+
}
61+
5462
let a = "A";
5563

5664
let b = "B";
@@ -67,4 +75,6 @@ exports.fpromise = fpromise;
6775
exports.Uncurried = Uncurried;
6876
exports.async_succ = async_succ;
6977
exports.async_foo = async_foo;
78+
exports.add = add;
79+
exports.partial_add = partial_add;
7080
/* Not a pure module */

0 commit comments

Comments
 (0)