forked from rescript-lang/syntax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.spec.js.snap
481 lines (300 loc) · 11.8 KB
/
parse.spec.js.snap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ambiguousArrow.js 1`] = `
"=====Parsetree==========================================
let a b = (\\"hi\\" : int)
let x = ((let a = 1 in let b = 2 in fun pattern -> (\\"test\\" : int))
[@ns.braces ])
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/ambiguousArrow.js\\", line 1, characters 8-21:
[31m1[0m │ let a = [31mb:int => \\"hi\\"[0m
2 │
3 │ let x = {
Did you mean to annotate the parameter type or the return type?
1) (b): int => \\"hi\\"
2) (b: int) => \\"hi\\"
File \\"/syntax/tests/parsing/errors/expressions/ambiguousArrow.js\\", line 6, characters 2-23:
4 │ let a = 1
5 │ let b = 2
[31m6[0m │ [31ma + b : int => \\"test\\"[0m
7 │ }
Did you mean to annotate the parameter type or the return type?
1) (pattern): int => \\"test\\"
2) (pattern: int) => \\"test\\"
========================================================"
`;
exports[`array.js 1`] = `
"=====Parsetree==========================================
let xs = x.map (fun key -> [|key;(predicates.(key))|])
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/array.js\\", line 2, characters 43-44:
1 │ // missing ] before )
[31m2[0m │ let xs = x.map(key => [key, predicates[key])
[31m^[0m
Did you forget a \`]\` here?
========================================================"
`;
exports[`arrow.js 1`] = `
"=====Parsetree==========================================
;;(Object.keys providers).reduce
(fun elements ->
fun providerId -> ((let x = 1 in let b = 2 in x + b)[@ns.braces ]))
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/arrow.js\\", line 1, characters 51-52:
[31m1[0m │ Object.keys(providers).reduce((elements, providerId] => {
[31m^[0m
2 │ let x = 1
3 │ let b = 2
Did you forget a \`,\` here?
========================================================"
`;
exports[`block.js 1`] = `
"=====Parsetree==========================================
let findThreadByIdLinearScan ~threads:((threads)[@ns.namedArgLoc ])
~id:((id)[@ns.namedArgLoc ]) =
((Js.Array2.findi ThreadsModel.threads
(fun thread ->
fun i ->
((let thisId =
match thread with
| ServerData.OneToOne { otherPersonIDWhichIsAlsoThreadID } ->
otherPersonIDWhichIsAlsoThreadID
| Group { id } -> id
| Unknown { id } ->
(unknown.id |. Js.String.make) |. FBID.ofStringUnsafe in
thisId == id)
[@ns.braces ])))
[@ns.braces ])
let x = ((loop 0 (Nil |. (push doc)))[@ns.braces ])
;;match stack with
| Empty -> [%napkinscript.exprhole ]
| Cons (doc, rest) -> ()
| Join (doc1, doc2) -> (buffer |. (Buffer.add_string indentation); loop ())
let pipeline =
match scheduler with | Some -> [%napkinscript.exprhole ] | None -> ()
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/block.js\\", line 14, characters 3-5:
12 │
13 │ thisId === id
[31m14[0m │ }
[31m^[0m
15 │ }
16 │
Did you forget a \`)\` here?
File \\"/syntax/tests/parsing/errors/expressions/block.js\\", line 18, characters 24-26:
16 │
17 │ let x = {
[31m18[0m │ loop(0, Nil->push(doc)
[31m^[0m
19 │ } // closing ) above is missing
20 │
Did you forget a \`)\` here?
File \\"/syntax/tests/parsing/errors/expressions/block.js\\", line 22, characters 10-12:
20 │
21 │ switch stack {
[31m22[0m │ | Empty =>
23 │ | Cons(doc, rest) => ()
24 │ | Join(doc1, doc2) =>
Looks like there might be an expression missing here
File \\"/syntax/tests/parsing/errors/expressions/block.js\\", line 26, characters 6-8:
24 │ | Join(doc1, doc2) =>
25 │ buffer->Buffer.add_string(indentation)
[31m26[0m │ loop(
[31m^[0m
27 │ }
28 │
Did you forget a \`)\` here?
File \\"/syntax/tests/parsing/errors/expressions/block.js\\", line 30, characters 9-11:
28 │
29 │ let pipeline = switch scheduler {
[31m30[0m │ | Some =>
31 │ | None => ()
32 │ }
Looks like there might be an expression missing here
========================================================"
`;
exports[`consecutive.ns 1`] = `
"=====Parsetree==========================================
let f a b = a + 3
;;b
let f g h = ((a + 3; b)[@ns.braces ])
let () = ((sideEffect1 (); sideEffect2 ())[@ns.braces ])
let () = ((let open Foo in let exception End in x ())[@ns.braces ])
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/consecutive.ns\\", line 1, characters 22-23:
[31m1[0m │ let f = (a,b) => a + 3[31mb[0m;
2 │
3 │ let f = (g, h) => {
consecutive statements on a line must be separated by ';' or a newline
File \\"/syntax/tests/parsing/errors/expressions/consecutive.ns\\", line 4, characters 6-7:
2 │
3 │ let f = (g, h) => {
[31m4[0m │ a + 3[31mb[0m
5 │ }
6 │
consecutive expressions on a line must be separated by ';' or a newline
File \\"/syntax/tests/parsing/errors/expressions/consecutive.ns\\", line 8, characters 15-27:
6 │
7 │ let () = {
[31m8[0m │ sideEffect1()[31m sideEffect2[0m()
9 │ }
10 │
consecutive expressions on a line must be separated by ';' or a newline
File \\"/syntax/tests/parsing/errors/expressions/consecutive.ns\\", line 12, characters 10-20:
10 │
11 │ let () = {
[31m12[0m │ open Foo[31m exception[0m End
13 │ x()
14 │ }
consecutive expressions on a line must be separated by ';' or a newline
========================================================"
`;
exports[`emptyBlock.js 1`] = `
"=====Parsetree==========================================
let x = ((())[@ns.braces ])
let f a b = ((())[@ns.braces ])
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/emptyBlock.js\\", line 1, characters 9-10:
[31m1[0m │ let x = {[31m}[0m
2 │
3 │ let f = (a, b) => {}
This let-binding misses an expression
File \\"/syntax/tests/parsing/errors/expressions/emptyBlock.js\\", line 3, characters 19-20:
1 │ let x = {}
2 │
[31m3[0m │ let f = (a, b) => {[31m}[0m
Missing expression
========================================================"
`;
exports[`guard.js 1`] = `
"=====Parsetree==========================================
;;((if a
then (((if c then [%napkinscript.exprhole ] else ()))[@ns.guard ])
else ((if b then [%napkinscript.exprhole ] else ())[@ns.guard ]))
[@ns.guard ])
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/guard.js\\", line 4, characters 5-32:
2 │ guard b else {
3 │ ()
[31m4[0m │ }
5 │ // }, missing a body
6 │ }
It seems that this expression block is empty
File \\"/syntax/tests/parsing/errors/expressions/guard.js\\", line 10, characters 1-25:
8 │ guard c else {
9 │ ()
[31m10[0m │ }
11 │ // eof, missing a body
It seems that this expression block is incomplete
========================================================"
`;
exports[`if.js 1`] = `
"=====Parsetree==========================================
;;if match then let a = 1 in a + 1
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/if.js\\", line 2, characters 10-16:
1 │ // missing brace below
[31m2[0m │ if (match)
[31m^[0m
3 │ let a = 1
4 │ a + 1
Did you forget a \`{\` here?
========================================================"
`;
exports[`misc.js 1`] = `
"=====Parsetree==========================================
let x = ([%napkinscript.exprhole ]) + 1
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/misc.js\\", line 1, characters 8-9:
[31m1[0m │ let x = [31m_[0m + 1
\`_\` isn't a valid name.
========================================================"
`;
exports[`record.js 1`] = `
"=====Parsetree==========================================
let newWrapper = { updateF; value = (f xWrapper.currentValue) }
let newWrapper = { updateF; updateF2; value = (f xWrapper.currentValue) }
let record = { field = ([%napkinscript.exprhole ]) }
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/record.js\\", line 2, characters 9-17:
1 │ let newWrapper = {
[31m2[0m │ updateF
[31m^[0m
3 │ value: f(xWrapper.currentValue),
4 │ }
Did you forget a \`,\` here?
File \\"/syntax/tests/parsing/errors/expressions/record.js\\", line 8, characters 9-18:
6 │
7 │ let newWrapper = {
[31m8[0m │ updateF updateF2
[31m^[0m
9 │ value: f(xWrapper.currentValue),
10 │ }
Did you forget a \`:\` here?
File \\"/syntax/tests/parsing/errors/expressions/record.js\\", line 13, characters 8-13:
11 │
12 │ let record = {
[31m13[0m │ field:
14 │ }
15 │
Missing expression
========================================================"
`;
exports[`setField.js 1`] = `
"=====Parsetree==========================================
;;if match
then
let a = 1 in (m.left).compatibleTypeArgs <- ([%napkinscript.exprhole ])
else sideEffect ()
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/setField.js\\", line 4, characters 29-31:
2 │ let a = 1
3 │ // notice missing expression after =
[31m4[0m │ m.left.compatibleTypeArgs =
5 │ } else {
6 │ sideEffect()
It seems that this record field mutation misses an expression
========================================================"
`;
exports[`taggedTemplateLiterals.js 1`] = `
"=====Parsetree==========================================
;;{|null|}
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/taggedTemplateLiterals.js\\", line 1, characters 0-5:
[31m1[0m │ [31mfoo()[0m\`null\`
Tagged template literals are currently restricted to identifiers like: json\`null\`.
========================================================"
`;
exports[`try.js 1`] = `
"=====Parsetree==========================================
let parsedPayload = try Js.Json.parseExn response with | _ -> Js.Json.null
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/try.js\\", line 2, characters 36-38:
1 │ let parsedPayload =
[31m2[0m │ try (Js.Json.parseExn(response)) {
[31m^^^^^[0m
3 │ | _ => Js.Json.null
4 │ }
Did you forget a \`catch\` here?
========================================================"
`;
exports[`unexpectedConstraint.js 1`] = `
"=====Parsetree==========================================
let x = ((let a = 1 in let b = 2 in (a + b : int))[@ns.braces ])
let x = (\\"hi\\" : string)
=====Errors=============================================
File \\"/syntax/tests/parsing/errors/expressions/unexpectedConstraint.js\\", line 4, characters 2-13:
2 │ let a = 1
3 │ let b = 2
[31m4[0m │ [31ma + b : int[0m
5 │ }
6 │
Expressions with type constraints need to be wrapped in parens:
(a + b: int)
File \\"/syntax/tests/parsing/errors/expressions/unexpectedConstraint.js\\", line 7, characters 8-20:
5 │ }
6 │
[31m7[0m │ let x = [31m\\"hi\\": string[0m
Expressions with type constraints need to be wrapped in parens:
(\\"hi\\": string)
========================================================"
`;