toml-lang / toml-test

A language agnostic test suite for TOML parsers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent handling of array of tables

opened this issue · comments

I'm testing a TOML encoder on testcase valid/array-table-array-string-backslash.
The encode under test outputs

[[foo]]
bar = "\"{{baz}}\""

while the testsuite expects

foo = [ { bar="\"{{baz}}\""} ]

Clearly these two TOML encodings are equivalent.
However, the toml-test tool reports failure:

Type mismatch for key 'foo'. Expected array but got []map[string]interface {}.

I believe this happens because the golden TOML parser uses different types for inline arrays versus arrays of tables. An inline array is parsed into a value of type []interface{}. But a double-bracketed array of tables is parsed into a value of type []map[string]interface{}. These are incompatible types according to the Go typesystem. As a result, the toml-test tool reports failure even though the answer is correct.