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

encoding/toml: incorrect duplicate key error for tables nested within an array of tables #3609

Open
qjcg opened this issue Dec 3, 2024 · 1 comment

Comments

@qjcg
Copy link

qjcg commented Dec 3, 2024

What version of CUE are you using (cue version)?

$ cue version
cue version v0.11.0

go version go1.23.3
      -buildmode exe
       -compiler gc
       -trimpath true
     CGO_ENABLED 0
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.11.0

Does this issue reproduce with the latest stable release?

Yes.

What did you do?

# eval cue example
exec cue eval example.cue

# eval equivalent toml example
exec cue eval example.toml
-- example.cue --
blocks: [
	{
		x: 42
		properties: {
			style: "plain"
		}
	},
	{
		x: 100
		properties: {
			style: "special"
		}
	},
]
-- example.toml --
[[blocks]]
x = 42

[blocks.properties]
style = 'plain'

[[blocks]]
x = 100

[blocks.properties]
style = 'special'

What did you expect to see?

Both cue eval commands run successfully with no errors.

What did you see instead?

$ cue eval example.toml
duplicate key: blocks.properties:
    ./example.toml:10:2

This is incorrect according to the TOML spec (v1.0.0), which states:

Any reference to an array of tables points to the most recently defined table element of the array. This allows you to define sub-tables, and even sub-arrays of tables, inside the most recent table.

This issue has the undesirable effect of breaking, for example, the cue eval and cue vet commands for TOML files containing such data.

@qjcg qjcg added NeedsInvestigation Triage Requires triage/attention labels Dec 3, 2024
@mvdan
Copy link
Member

mvdan commented Dec 3, 2024

Thanks for reporting. It's entirely possible that I got the logic for arrays of tables slightly wrong. I'll take a look when I can; you're more than welcome to try debugging our code in the meantime.

@mvdan mvdan removed the Triage Requires triage/attention label Dec 3, 2024
@myitcv myitcv changed the title TOML incorrect duplicate key error for tables nested within an array of tables encoding/toml: incorrect duplicate key error for tables nested within an array of tables Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants