File tree Expand file tree Collapse file tree 3 files changed +92
-26
lines changed
tests/parsing/errors/scanner Expand file tree Collapse file tree 3 files changed +92
-26
lines changed Original file line number Diff line number Diff line change @@ -283,11 +283,12 @@ let scanNumber scanner =
283
283
else Token. Int {i = literal; suffix}
284
284
285
285
let scanExoticIdentifier scanner =
286
- (* TODO: are we disregarding the current char...? Should be a quote *)
287
- next scanner;
288
286
let buffer = Buffer. create 20 in
289
287
let startPos = position scanner in
290
288
289
+ (* TODO: are we disregarding the current char...? Should be a quote *)
290
+ next scanner;
291
+
291
292
let rec scan () =
292
293
match scanner.ch with
293
294
| '"' -> next scanner
@@ -307,8 +308,17 @@ let scanExoticIdentifier scanner =
307
308
scan ()
308
309
in
309
310
scan () ;
311
+
312
+ let ident = Buffer. contents buffer in
313
+ let _ =
314
+ if ident = " " then
315
+ let endPos = position scanner in
316
+ scanner.err ~start Pos ~end Pos
317
+ (Diagnostics. message " A quoted identifier can't be empty string." )
318
+ in
319
+
310
320
(* TODO: do we really need to create a new buffer instead of substring once? *)
311
- Token. Lident ( Buffer. contents buffer)
321
+ Token. Lident ident
312
322
313
323
let scanStringEscapeSequence ~startPos scanner =
314
324
let scan ~n ~base ~max =
Original file line number Diff line number Diff line change
1
+ type \""
2
+
3
+ type \"" = int
4
+
5
+ let \""
6
+
1
7
let \"a
2
8
b
3
9
c" = 1
Original file line number Diff line number Diff line change 1
1
2
2
Syntax error!
3
- tests/parsing/errors/scanner/exoticIdent.res:1:7
3
+ tests/parsing/errors/scanner/exoticIdent.res:1:7-8
4
4
5
- 1 │ let \"a
6
- 2 │ b
7
- 3 │ c" = 1
5
+ 1 │ type \""
6
+ 2 │
7
+ 3 │ type \"" = int
8
8
9
- A quoted identifier can't contain line breaks .
9
+ A quoted identifier can't be empty string .
10
10
11
11
12
12
Syntax error!
13
- tests/parsing/errors/scanner/exoticIdent.res:2:1
13
+ tests/parsing/errors/scanner/exoticIdent.res:3:7-8
14
14
15
- 1 │ let \"a
16
- 2 │ b
17
- 3 │ c" = 1
15
+ 1 │ type \""
16
+ 2 │
17
+ 3 │ type \"" = int
18
18
4 │
19
+ 5 │ let \""
19
20
20
- Did you forget a `=` here?
21
+ A quoted identifier can't be empty string.
21
22
22
23
23
24
Syntax error!
24
- tests/parsing/errors/scanner/exoticIdent.res:3:2-4:0
25
+ tests/parsing/errors/scanner/exoticIdent.res:5:6-7
25
26
26
- 1 │ let \"a
27
- 2 │ b
28
- 3 │ c" = 1
27
+ 3 │ type \"" = int
29
28
4 │
29
+ 5 │ let \""
30
+ 6 │
31
+ 7 │ let \"a
30
32
31
- This string is missing a double quote at the end
33
+ A quoted identifier can't be empty string.
32
34
33
35
34
36
Syntax error!
35
- tests/parsing/errors/scanner/exoticIdent.res:3:2-4:0
37
+ tests/parsing/errors/scanner/exoticIdent.res:5:8-7:3
36
38
37
- 1 │ let \"a
38
- 2 │ b
39
- 3 │ c" = 1
39
+ 3 │ type \"" = int
40
40
4 │
41
+ 5 │ let \""
42
+ 6 │
43
+ 7 │ let \"a
44
+ 8 │ b
45
+ 9 │ c" = 1
46
+
47
+ Did you forget a `=` here?
48
+
49
+
50
+ Syntax error!
51
+ tests/parsing/errors/scanner/exoticIdent.res:7:6-7
52
+
53
+ 5 │ let \""
54
+ 6 │
55
+ 7 │ let \"a
56
+ 8 │ b
57
+ 9 │ c" = 1
58
+
59
+ A quoted identifier can't contain line breaks.
60
+
61
+
62
+ Syntax error!
63
+ tests/parsing/errors/scanner/exoticIdent.res:8:1
64
+
65
+ 6 │
66
+ 7 │ let \"a
67
+ 8 │ b
68
+ 9 │ c" = 1
69
+ 10 │
70
+
71
+ Did you forget a `=` here?
72
+
73
+
74
+ Syntax error!
75
+ tests/parsing/errors/scanner/exoticIdent.res:9:2-10:0
76
+
77
+ 7 │ let \"a
78
+ 8 │ b
79
+ 9 │ c" = 1
80
+ 10 │
81
+
82
+ This string is missing a double quote at the end
83
+
84
+
85
+ Syntax error!
86
+ tests/parsing/errors/scanner/exoticIdent.res:9:2-10:0
87
+
88
+ 7 │ let \"a
89
+ 8 │ b
90
+ 9 │ c" = 1
91
+ 10 │
41
92
42
93
consecutive statements on a line must be separated by ';' or a newline
43
94
44
- let a = b
45
- ;;c
46
- ;;{js| = 1
47
- |js}
95
+ type nonrec
96
+ type nonrec = int
97
+ let Fatal error: exception Invalid_argument("index out of bounds")
You can’t perform that action at this time.
0 commit comments