Skip to content

Commit 73b6e23

Browse files
committed
Add test case for future splice support
1 parent 55ae363 commit 73b6e23

File tree

1 file changed

+270
-0
lines changed

1 file changed

+270
-0
lines changed

Diff for: shared/src/test/diff/nu/Splices.mls

+270
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
:NewDefs
2+
3+
4+
let bs = [1, 2, 3]
5+
//│ let bs: [1, 2, 3]
6+
//│ bs
7+
//│ = [ 1, 2, 3 ]
8+
9+
:pe // TODO
10+
let t = [0, ...bs]
11+
//│ ╔══[PARSE ERROR] Unexpected operator here
12+
//│ ║ l.10: let t = [0, ...bs]
13+
//│ ╙── ^^^
14+
//│ let t: [0]
15+
//│ t
16+
//│ = [ 0 ]
17+
18+
t.0
19+
//│ 0
20+
//│ res
21+
//│ = 0
22+
23+
:e // TODO
24+
t.1
25+
//│ ╔══[ERROR] Type mismatch in field selection:
26+
//│ ║ l.24: t.1
27+
//│ ║ ^^^
28+
//│ ╟── definition of let binding t of type `{0: 0}` does not have field '1'
29+
//│ ║ l.10: let t = [0, ...bs]
30+
//│ ║ ^^^^^^^^^^^^^^
31+
//│ ╟── but it flows into reference with expected type `{1: ?a}`
32+
//│ ║ l.24: t.1
33+
//│ ╙── ^
34+
//│ error
35+
//│ res
36+
//│ = undefined
37+
38+
:e // TODO
39+
t.2
40+
//│ ╔══[ERROR] Type mismatch in field selection:
41+
//│ ║ l.39: t.2
42+
//│ ║ ^^^
43+
//│ ╟── definition of let binding t of type `{0: 0}` does not have field '2'
44+
//│ ║ l.10: let t = [0, ...bs]
45+
//│ ║ ^^^^^^^^^^^^^^
46+
//│ ╟── but it flows into reference with expected type `{2: ?a}`
47+
//│ ║ l.39: t.2
48+
//│ ╙── ^
49+
//│ error
50+
//│ res
51+
//│ = undefined
52+
53+
:e
54+
t.3
55+
//│ ╔══[ERROR] Type mismatch in field selection:
56+
//│ ║ l.54: t.3
57+
//│ ║ ^^^
58+
//│ ╟── definition of let binding t of type `{0: 0}` does not have field '3'
59+
//│ ║ l.10: let t = [0, ...bs]
60+
//│ ║ ^^^^^^^^^^^^^^
61+
//│ ╟── but it flows into reference with expected type `{3: ?a}`
62+
//│ ║ l.54: t.3
63+
//│ ╙── ^
64+
//│ error
65+
//│ res
66+
//│ = undefined
67+
68+
69+
let cs: Array[Int] = bs
70+
//│ let cs: Array[Int]
71+
//│ cs
72+
//│ = [ 1, 2, 3 ]
73+
74+
:pe // TODO
75+
let t = [0, ...cs]
76+
//│ ╔══[PARSE ERROR] Unexpected operator here
77+
//│ ║ l.75: let t = [0, ...cs]
78+
//│ ╙── ^^^
79+
//│ let t: [0]
80+
//│ t
81+
//│ = [ 0 ]
82+
83+
t.0
84+
//│ 0
85+
//│ res
86+
//│ = 0
87+
88+
:e
89+
t.1
90+
//│ ╔══[ERROR] Type mismatch in field selection:
91+
//│ ║ l.89: t.1
92+
//│ ║ ^^^
93+
//│ ╟── definition of let binding t of type `{0: 0}` does not have field '1'
94+
//│ ║ l.75: let t = [0, ...cs]
95+
//│ ║ ^^^^^^^^^^^^^^
96+
//│ ╟── but it flows into reference with expected type `{1: ?a}`
97+
//│ ║ l.89: t.1
98+
//│ ╙── ^
99+
//│ error
100+
//│ res
101+
//│ = undefined
102+
103+
104+
:pe // TODO
105+
fun f(x, y, ...zs) = x
106+
//│ ╔══[PARSE ERROR] Unexpected operator here
107+
//│ ║ l.105: fun f(x, y, ...zs) = x
108+
//│ ╙── ^^^
109+
//│ fun f: forall 'a. ('a, anything) -> 'a
110+
111+
f(0, 1)
112+
//│ 0
113+
//│ res
114+
//│ = 0
115+
116+
:e // TODO
117+
f(0, 1, 2)
118+
//│ ╔══[ERROR] Type mismatch in application:
119+
//│ ║ l.117: f(0, 1, 2)
120+
//│ ║ ^^^^^^^^^^
121+
//│ ╟── argument list of type `[0, 1, 2]` does not match type `[?a, ?b]`
122+
//│ ║ l.117: f(0, 1, 2)
123+
//│ ║ ^^^^^^^^^
124+
//│ ╟── Note: constraint arises from tuple literal:
125+
//│ ║ l.105: fun f(x, y, ...zs) = x
126+
//│ ╙── ^^^^^^^^^^^^^
127+
//│ error
128+
//│ res
129+
//│ = 0
130+
131+
:e // TODO
132+
f(0, 1, 2, 3)
133+
//│ ╔══[ERROR] Type mismatch in application:
134+
//│ ║ l.132: f(0, 1, 2, 3)
135+
//│ ║ ^^^^^^^^^^^^^
136+
//│ ╟── argument list of type `[0, 1, 2, 3]` does not match type `[?a, ?b]`
137+
//│ ║ l.132: f(0, 1, 2, 3)
138+
//│ ║ ^^^^^^^^^^^^
139+
//│ ╟── Note: constraint arises from tuple literal:
140+
//│ ║ l.105: fun f(x, y, ...zs) = x
141+
//│ ╙── ^^^^^^^^^^^^^
142+
//│ error
143+
//│ res
144+
//│ = 0
145+
146+
:e // TODO
147+
f(0)
148+
//│ ╔══[ERROR] Type mismatch in application:
149+
//│ ║ l.147: f(0)
150+
//│ ║ ^^^^
151+
//│ ╟── argument of type `[0]` does not match type `[?a, ?b]`
152+
//│ ║ l.147: f(0)
153+
//│ ║ ^^^
154+
//│ ╟── Note: constraint arises from tuple literal:
155+
//│ ║ l.105: fun f(x, y, ...zs) = x
156+
//│ ╙── ^^^^^^^^^^^^^
157+
//│ error
158+
//│ res
159+
//│ = 0
160+
161+
:pe // TODO
162+
:e // TODO
163+
f(...bs)
164+
//│ ╔══[PARSE ERROR] Unexpected operator here
165+
//│ ║ l.163: f(...bs)
166+
//│ ╙── ^^^
167+
//│ ╔══[ERROR] Type mismatch in application:
168+
//│ ║ l.163: f(...bs)
169+
//│ ║ ^^^^^^^^
170+
//│ ╟── argument of type `[]` does not match type `[?a, ?b]`
171+
//│ ║ l.163: f(...bs)
172+
//│ ║ ^^^^^^^
173+
//│ ╟── Note: constraint arises from tuple literal:
174+
//│ ║ l.105: fun f(x, y, ...zs) = x
175+
//│ ╙── ^^^^^^^^^^^^^
176+
//│ error
177+
//│ res
178+
//│ = undefined
179+
180+
:pe // TODO
181+
:e // TODO
182+
f(0, ...bs)
183+
//│ ╔══[PARSE ERROR] Unexpected operator here
184+
//│ ║ l.182: f(0, ...bs)
185+
//│ ╙── ^^^
186+
//│ ╔══[ERROR] Type mismatch in application:
187+
//│ ║ l.182: f(0, ...bs)
188+
//│ ║ ^^^^^^^^^^^
189+
//│ ╟── argument of type `[0]` does not match type `[?a, ?b]`
190+
//│ ║ l.182: f(0, ...bs)
191+
//│ ║ ^^^^^^^^^^
192+
//│ ╟── Note: constraint arises from tuple literal:
193+
//│ ║ l.105: fun f(x, y, ...zs) = x
194+
//│ ╙── ^^^^^^^^^^^^^
195+
//│ error
196+
//│ res
197+
//│ = 0
198+
199+
:pe // TODO
200+
f(0, 1, ...bs)
201+
//│ ╔══[PARSE ERROR] Unexpected operator here
202+
//│ ║ l.200: f(0, 1, ...bs)
203+
//│ ╙── ^^^
204+
//│ 0
205+
//│ res
206+
//│ = 0
207+
208+
209+
:pe // TODO
210+
fun f: 'xs -> [1, 2, ...'xs]
211+
//│ ╔══[PARSE ERROR] Unexpected operator here
212+
//│ ║ l.210: fun f: 'xs -> [1, 2, ...'xs]
213+
//│ ╙── ^^^
214+
//│ fun f: anything -> [1, 2]
215+
216+
f([])
217+
//│ [1, 2]
218+
//│ res
219+
//│ = <no result>
220+
//│ f is not implemented
221+
222+
f([1])
223+
//│ [1, 2]
224+
//│ res
225+
//│ = <no result>
226+
//│ f is not implemented
227+
228+
f([1, 2])
229+
//│ [1, 2]
230+
//│ res
231+
//│ = <no result>
232+
//│ f is not implemented
233+
234+
f(bs)
235+
//│ [1, 2]
236+
//│ res
237+
//│ = <no result>
238+
//│ f is not implemented
239+
240+
f(cs)
241+
//│ [1, 2]
242+
//│ res
243+
//│ = <no result>
244+
//│ f is not implemented
245+
246+
:e
247+
f()
248+
//│ ╔══[ERROR] Type mismatch in application:
249+
//│ ║ l.247: f()
250+
//│ ║ ^^^
251+
//│ ╟── argument of type `[]` does not match type `['xs]`
252+
//│ ║ l.247: f()
253+
//│ ║ ^^
254+
//│ ╟── Note: constraint arises from tuple type:
255+
//│ ║ l.210: fun f: 'xs -> [1, 2, ...'xs]
256+
//│ ╙── ^^^
257+
//│ error | [1, 2]
258+
//│ res
259+
//│ = <no result>
260+
//│ f is not implemented
261+
262+
// :e // TODO
263+
f(0)
264+
//│ [1, 2]
265+
//│ res
266+
//│ = <no result>
267+
//│ f is not implemented
268+
269+
270+

0 commit comments

Comments
 (0)