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

Duplicate key allowed in inline table #658

Closed
moorereason opened this issue Nov 5, 2021 · 5 comments
Closed

Duplicate key allowed in inline table #658

moorereason opened this issue Nov 5, 2021 · 5 comments
Labels
bug Issues describing a bug in go-toml. v2 Issues impacting the v2 major version.

Comments

@moorereason
Copy link
Contributor

Describe the bug
Given e={b=1,b=4}, go-toml returns the following (using gotoml-test-decoder):

{
  "e": {
    "b": {
      "type": "integer",
      "value": "4"
    }
  }
}

To Reproduce
https://play.golang.org/p/by7ih3epoCp

toml.Unmarshal([]byte("e={b=1,b=4}"), &v)

Expected behavior
I expected an error. The TOML spec says:

Defining a key multiple times is invalid.

BurntSushi returns an error of Key 'e.b' has already been defined.

Versions

  • go-toml: 11f789e
  • go version devel go1.18-6294207a1c7 Tue Oct 19 15:03:39 2021 +0000 linux/amd64

Additional context
Found while doing differential fuzzing against BurntSushi.

@moorereason
Copy link
Contributor Author

Once this is fixed, we can regen the toml-test files to include toml-lang/toml-test#93.

@pelletier pelletier added bug Issues describing a bug in go-toml. v2 Issues impacting the v2 major version. labels Nov 7, 2021
@pelletier
Copy link
Owner

Started working on this, but realized there is some part of the spec that is unclear to me: toml-lang/toml#848 (comment).

Let me know if you have any thoughts on how we should handle dotted keys in inline tables!

@moorereason
Copy link
Contributor Author

My take:

  1. Dotted keys within a table definition should be treated the same regardless of the type of table (standard or inline).
  2. Dotted keys within a table are acceptable so long as the sub-tables are fully defined within the current table context. That clarification appears to be the point of the toml PR referenced above.

@pelletier
Copy link
Owner

👍🏻 Went with that interpretation until they chime in.

pelletier added a commit that referenced this issue Nov 9, 2021
pelletier added a commit that referenced this issue Nov 9, 2021
@pelletier
Copy link
Owner

Regenerated the toml-test files to include the new test. Let me know if i've missed anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues describing a bug in go-toml. v2 Issues impacting the v2 major version.
Projects
None yet
Development

No branches or pull requests

2 participants