You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 15, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: tests/parsing/errors/other/expected/spread.res.txt
+15-1Lines changed: 15 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,20 @@ Explanation: you can't collect a subset of a record's field into its own record,
49
49
Solution: you need to pull out each field you want explicitly.
50
50
51
51
52
+
Syntax error!
53
+
tests/parsing/errors/other/spread.res:8:1-3
54
+
55
+
6 │
56
+
7 │ let myList = list{...x, ...y}
57
+
8 │ let list{...x, ...y} = myList
58
+
9 │
59
+
10 │ type t = {...a}
60
+
61
+
Lists can only have one `...` spread, and at the end.
62
+
Explanation: lists are singly-linked list, where a node contains a value and points to the next node. `list{a, ...bc}` efficiently creates a new item and links `bc` as its next nodes. `list{...bc, a}` would be expensive, as it'd need to traverse `bc` and prepend each item to `a` one by one. We therefore disallow such syntax sugar.
63
+
Solution: directly use `concat`.
64
+
65
+
52
66
Syntax error!
53
67
tests/parsing/errors/other/spread.res:8:13-22
54
68
@@ -59,7 +73,7 @@ Solution: you need to pull out each field you want explicitly.
59
73
10 │ type t = {...a}
60
74
61
75
List pattern matches only supports one `...` spread, at the end.
62
-
Explanation: a list spread at the tail is efficient, but a spread in the middle would create new list[s]; out of performance concern, our pattern matching currently guarantees to never create new intermediate data.
76
+
Explanation: a list spread at the tail is efficient, but a spread in the middle would create new lists; out of performance concern, our pattern matching currently guarantees to never create new intermediate data.
0 commit comments