Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to load toml file with array-table #39

Open
oldkingOK opened this issue Mar 14, 2024 · 2 comments
Open

Fail to load toml file with array-table #39

oldkingOK opened this issue Mar 14, 2024 · 2 comments

Comments

@oldkingOK
Copy link

oldkingOK commented Mar 14, 2024

Using latest Tomlet (5.3.0)

Code

using Tomlet;
...
var doc = new TomlParser().Parse("test.toml")

test.toml

[[a.b]]
name = "nick"
ishuman = true

[[a.b]]
name = "jack"
ishuman = false

Log

Unhandled exception. Tomlet.Exceptions.MissingIntermediateInTomlTableArraySpecException: Missing intermediate definition for a.b in table-array specification on line 1. This is undefined behavior, and I chose to define it as an error.
   at Tomlet.TomlParser.ReadTableArrayStatement(TomletStringReader reader, TomlDocument document) in /_/Tomlet/TomlParser.cs:line 911
   at Tomlet.TomlParser.Parse(String input) in /_/Tomlet/TomlParser.cs:line 65
   at Tomlet.TomlParser.ParseFile(String filePath) in /_/Tomlet/TomlParser.cs:line 30
   at Program.Main(String[] args)
@oldkingOK
Copy link
Author

It works with test.toml:

[[a]]

[[a.b]]
name = "nick"
ishuman = true

[[a.b]]
name = "jack"
ishuman = false

While the TOML 1.0.0 specification allows us to ignore the parent node definition.

@SamboyCoding
Copy link
Owner

Coming back to this, I'm not seeing anywhere in the TOML spec that actually says this is allowed, and they show many similar cases which are not allowed, so I'm not inclined to allow this behavior. There's a certain lack of clarity here - you're defining, essentially, an array b of name, ishuman on a table a, but you don't define a anywhere earlier, so it's ambiguous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants