marzer / tomlplusplus

Header-only TOML config file parser and serializer for C++17.
https://marzer.github.io/tomlplusplus/
MIT License
1.53k stars 146 forks source link

Rejects definition of super-table of table array #187

Closed ghost closed 1 year ago

ghost commented 1 year ago

The non-conforming TOML snippet

[[a.b]]
x = 1

[a]
y = 2

This testcase is part of toml-test: https://github.com/BurntSushi/toml-test/blob/master/tests/valid/table/array-implicit-and-explicit-after.toml

What you expected

This is a valid TOML document which should be parsed as {"a": {"b": [{"x": 1}], "y": 2}}

The TOML 1.0.0 spec gives the following example as valid:

[x.y.z.w]
[x] # defining a super-table afterward is ok

There is no reason why an implicit super-table should be treated differently when created by a table-array definition vs a table definition. Nothing in the TOML spec suggests that super-tables of table arrays should be considered as defined instead of merely implicitly created.

What you got

Error while parsing table header: cannot redefine existing table 'a'
        (error occurred at line 4, column 1 of 'stdin')

Environment

toml++ version and/or commit hash:
version v3.2.0, commit 698285d9b2f3f6756fcdab8b93f60352325764e1 on master branch

Any other useful information:

marzer commented 1 year ago

Ah, thanks for the report. I'll look into this later today :)

marzer commented 1 year ago

Sorry, ran out of time. Will have a look during the week.

ghost commented 1 year ago

Thanks for looking into it. Please take the time you need.

To be clear, this issue is not blocking me in any way. I just happened to notice this and created an issue because getting this fixed may be good for your project in the long run. But it is of course up to you to decide whether this has any priority.

marzer commented 1 year ago

I've fixed this in 3.3.0, thanks again for the report!