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 @@ -291,11 +291,12 @@ let scanNumber scanner =
291
291
else Token. Int {i = literal; suffix}
292
292
293
293
let scanExoticIdentifier scanner =
294
- (* TODO: are we disregarding the current char...? Should be a quote *)
295
- next scanner;
296
294
let buffer = Buffer. create 20 in
297
295
let startPos = position scanner in
298
296
297
+ (* TODO: are we disregarding the current char...? Should be a quote *)
298
+ next scanner;
299
+
299
300
let rec scan () =
300
301
match scanner.ch with
301
302
| '"' -> next scanner
@@ -315,8 +316,17 @@ let scanExoticIdentifier scanner =
315
316
scan ()
316
317
in
317
318
scan () ;
319
+
320
+ let ident = Buffer. contents buffer in
321
+ let _ =
322
+ if ident = " " then
323
+ let endPos = position scanner in
324
+ scanner.err ~start Pos ~end Pos
325
+ (Diagnostics. message " A quoted identifier can't be empty string." )
326
+ in
327
+
318
328
(* TODO: do we really need to create a new buffer instead of substring once? *)
319
- Token. Lident ( Buffer. contents buffer)
329
+ Token. Lident ident
320
330
321
331
let scanStringEscapeSequence ~startPos scanner =
322
332
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