diff --git a/vlib/toml/checker/checker.v b/vlib/toml/checker/checker.v index feaed8af5d..109d76464b 100644 --- a/vlib/toml/checker/checker.v +++ b/vlib/toml/checker/checker.v @@ -22,11 +22,14 @@ pub fn (c Checker) check(n &ast.Value) ? { fn (c Checker) visit(value &ast.Value) ? { match value { + ast.Bool { + c.check_boolean(value) ? + } ast.Number { c.check_number(value) ? } - ast.Bool { - c.check_boolean(value) ? + ast.Quoted { + c.check_quoted(value) ? } else { // TODO add more checks to make BurntSushi/toml-test invalid TOML pass @@ -168,3 +171,13 @@ fn (c Checker) check_boolean(b ast.Bool) ? { return error(@MOD + '.' + @STRUCT + '.' + @FN + ' boolean values like "$lit" can only be `true` or `false` literals, not `$lit` in ...${c.excerpt(b.pos)}...') } + +fn (c Checker) check_quoted(b ast.Quoted) ? { + lit := b.text + quote := b.quote.ascii_str() + triple_quote := quote + quote + quote + if b.is_multiline && lit.ends_with(triple_quote) { + return error(@MOD + '.' + @STRUCT + '.' + @FN + + ' string values like "$lit" is has unbalanced quote literals `b.quote` in ...${c.excerpt(b.pos)}...') + } +} diff --git a/vlib/toml/tests/burntsushi.toml-test_test.v b/vlib/toml/tests/burntsushi.toml-test_test.v index 8f3c06ffdb..69a8eff371 100644 --- a/vlib/toml/tests/burntsushi.toml-test_test.v +++ b/vlib/toml/tests/burntsushi.toml-test_test.v @@ -18,14 +18,10 @@ const ( 'string/basic-byte-escapes.toml', 'string/multiline-escape-space.toml', 'string/bad-codepoint.toml', - 'string/literal-multiline-quotes-1.toml', - 'string/literal-multiline-quotes-2.toml', - 'string/multiline-quotes-1.toml', 'string/basic-multiline-out-of-range-unicode-escape-2.toml', 'string/bad-slash-escape.toml', 'string/basic-out-of-range-unicode-escape-1.toml', 'string/basic-out-of-range-unicode-escape-2.toml', - 'string/multiline-quotes-2.toml', 'string/bad-uni-esc.toml', 'string/bad-escape.toml', 'string/basic-multiline-unknown-escape.toml',