Skip to content

Commit 39dd8b6

Browse files
authored
fix(parser): Improve bad quote error messages (#1014)
Fixes #1013
2 parents 137338e + d5b8c8a commit 39dd8b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+189
-262
lines changed

crates/toml/tests/snapshots/invalid/array/missing-separator-01.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ TOML parse error at line 1, column 9
22
|
33
1 | arrr = [true false]
44
| ^^^^^^^^^^
5-
invalid boolean, expected `true`
5+
string values must be quoted, expected literal string
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
TOML parse error at line 1, column 15
2-
|
3-
1 | wrong = [ 1 2 3 ]
4-
| ^
5-
missing comma between array elements, expected `,`
6-
7-
---
81
TOML parse error at line 1, column 11
92
|
103
1 | wrong = [ 1 2 3 ]
11-
| ^^^
4+
| ^^^^^
125
string values must be quoted, expected literal string

crates/toml/tests/snapshots/invalid/array/no-comma-01.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ TOML parse error at line 1, column 15
22
|
33
1 | no-comma-1 = [true false]
44
| ^^^^^^^^^^
5-
invalid boolean, expected `true`
5+
string values must be quoted, expected literal string
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
TOML parse error at line 1, column 20
2-
|
3-
1 | no-comma-2 = [ 1 2 3 ]
4-
| ^
5-
missing comma between array elements, expected `,`
6-
7-
---
81
TOML parse error at line 1, column 16
92
|
103
1 | no-comma-2 = [ 1 2 3 ]
11-
| ^^^
4+
| ^^^^^
125
string values must be quoted, expected literal string

crates/toml/tests/snapshots/invalid/array/no-comma-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ TOML parse error at line 1, column 15
22
|
33
1 | no-comma-1 = [true false]
44
| ^^^^^^^^^^
5-
invalid boolean, expected `true`
5+
string values must be quoted, expected literal string
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
TOML parse error at line 1, column 20
2-
|
3-
1 | no-comma-2 = [ 1 2 3 ]
4-
| ^
5-
missing comma between array elements, expected `,`
6-
7-
---
81
TOML parse error at line 1, column 16
92
|
103
1 | no-comma-2 = [ 1 2 3 ]
11-
| ^^^
4+
| ^^^^^
125
string values must be quoted, expected literal string
Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,5 @@
1-
TOML parse error at line 3, column 8
2-
|
3-
3 | I don't belong,
4-
| ^
5-
missing comma between array elements, expected `,`
6-
7-
---
8-
TOML parse error at line 4, column 3
9-
|
10-
4 | "Entry 2",
11-
| ^
12-
missing comma between array elements, expected `,`
13-
14-
---
151
TOML parse error at line 3, column 3
162
|
173
3 | I don't belong,
18-
| ^^^^^
19-
invalid float, expected `inf`
20-
21-
---
22-
TOML parse error at line 3, column 18
23-
|
24-
3 | I don't belong,
25-
| ^
26-
invalid literal string, expected `'`
4+
| ^^^^^^^^^^^^^^
5+
string values must be quoted, expected literal string

crates/toml/tests/snapshots/invalid/inline-table/no-comma-02.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ TOML parse error at line 1, column 26
2323
|
2424
1 | arrr = { comma-missing = true valid-toml = false }
2525
| ^^^^^^^^^^^^^^^
26-
invalid boolean, expected `true`
26+
string values must be quoted, expected literal string
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
TOML parse error at line 1, column 17
1+
TOML parse error at line 1, column 10
22
|
33
1 | answer = 42 the ultimate answer?
4-
| ^
5-
unexpected key or value, expected newline, `#`
6-
7-
---
8-
TOML parse error at line 1, column 12
9-
|
10-
1 | answer = 42 the ultimate answer?
11-
| ^^^^
12-
invalid float, expected nothing
4+
| ^^^^^^^^^^^^^^^^^^^^^^^
5+
string values must be quoted, expected literal string

crates/toml/tests/snapshots/invalid/key/newline-02.stderr

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ TOML parse error at line 1, column 8
44
| ^
55
key with no value, expected `=`
66

7-
---
8-
TOML parse error at line 2, column 4
9-
|
10-
2 | key" = 1
11-
| ^
12-
key with no value, expected `=`
13-
147
---
158
TOML parse error at line 1, column 8
169
|

0 commit comments

Comments
 (0)