Skip to content

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

@qjcg

Description

@qjcg

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions