File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -762,9 +762,7 @@ pub fn (mut p Parser) key() ?ast.Key {
762
762
ast.Key (p.quoted ())
763
763
}
764
764
else {
765
- error (@MOD + '.' + @STRUCT + '.' + @FN +
766
- ' key expected .bare, .number, .quoted or .boolean but got "$p.tok.kind "' )
767
- ast.Key (ast.Bare{}) // TODO workaround bug
765
+ ast.Key (ast.Null{})
768
766
}
769
767
}
770
768
}
@@ -774,6 +772,24 @@ pub fn (mut p Parser) key() ?ast.Key {
774
772
// panic(@MOD + '.' + @STRUCT + '.' + @FN + ' could not parse ${p.tok.kind} ("${p.tok.lit}") token \n$p.tok')
775
773
// return ast.Key(ast.Bare{})
776
774
775
+ if key is ast.Null {
776
+ return error (@MOD + '.' + @STRUCT + '.' + @FN +
777
+ ' key expected .bare, .number, .quoted or .boolean but got "$p.tok.kind "' )
778
+ }
779
+
780
+ // A small exception that can't easily be done via `checker`
781
+ // since the `is_multiline` information is lost when using the key.text as a
782
+ // V `map` key directly.
783
+ if p.config.run_checks {
784
+ if key is ast.Quoted {
785
+ quoted := key as ast.Quoted
786
+ if quoted.is_multiline {
787
+ return error (@MOD + '.' + @STRUCT + '.' + @FN +
788
+ ' multiline string as key is not allowed. (excerpt): "...${p.excerpt()} ..."' )
789
+ }
790
+ }
791
+ }
792
+
777
793
return key
778
794
}
779
795
Original file line number Diff line number Diff line change @@ -42,7 +42,6 @@ const (
42
42
'key/without-value-2.toml' ,
43
43
'key/no-eol.toml' ,
44
44
'key/after-array.toml' ,
45
- 'key/multiline.toml' ,
46
45
]
47
46
)
48
47
You can’t perform that action at this time.
0 commit comments