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

Global tables create conflict with subtables #18

Closed
sparrc opened this issue Feb 8, 2016 · 1 comment
Closed

Global tables create conflict with subtables #18

sparrc opened this issue Feb 8, 2016 · 1 comment

Comments

@sparrc
Copy link

sparrc commented Feb 8, 2016

I'm getting an error parsing the [tags] sections in valid toml that looks like this:

# Global tags
[tags]
  shipment = "2a"

# Create list of tables with subtables

[[fruits.apple]]
  type = "red delicious"
  [fruits.apple.tags]
    PLU = 4555

[[fruits.apple]]
  type = "granny smith"
  [fruits.apple.tags]
    PLU = 4556

If I remove the global [tags] heading, or if I only set [fruits.apple.tags] once, the parsing works.

Below are some scripts for reproducing:

package main

import (
    "fmt"

    "github.com/naoina/toml"
)

// Global tags cause failure
const fruits = `
# Global tags
[tags]
  shipment = "2a"

# Create list of tables with subtables

[[fruits.apple]]
  type = "red delicious"
  [fruits.apple.tags]
    PLU = 4555

[[fruits.apple]]
  type = "granny smith"
  [fruits.apple.tags]
    PLU = 4556
`

func main() {
    _, err := toml.Parse([]byte(fruits))
    if err != nil {
        fmt.Println(err.Error())
        return
    }
}

it outputs:

% go run /tmp/config.go
toml: line 15: table `fruits.apple.tags' is in conflict with normal table in line 10

but if I take out the global [tags] table, it works:

package main

import (
    "fmt"

    "github.com/naoina/toml"
)

// This one works!
const fruits = `
# Create list of tables with subtables

[[fruits.apple]]
  type = "red delicious"
  [fruits.apple.tags]
    PLU = 4555

[[fruits.apple]]
  type = "granny smith"
  [fruits.apple.tags]
    PLU = 4556
`

func main() {
    _, err := toml.Parse([]byte(fruits))
    if err != nil {
        fmt.Println(err.Error())
        return
    }
}

or if I remove one of the [fruits.apple.tags] sections, it also parses OK:

package main

import (
    "fmt"

    "github.com/naoina/toml"
)

// This one works!
const fruits = `
# Create list of tables with subtables

[[fruits.apple]]
  type = "red delicious"

[[fruits.apple]]
  type = "granny smith"
  [fruits.apple.tags]
    PLU = 4556
`

func main() {
    _, err := toml.Parse([]byte(fruits))
    if err != nil {
        fmt.Println(err.Error())
        return
    }
}
@maxsz
Copy link

maxsz commented Feb 6, 2017

I'm having the same problem with the following (valid) TOML:

[message_queue]
client_name = "HVAC"

[[devices]]
address = 88 # 0x58
channel = 0
	[devices.message_queue]
	subscribe = "..."
	[devices.calibration_data]
	register_size = 1024

toml: line 22: table devices.message_queue' is in conflict with normal table in line 11`

@naoina any thoughts about this?

@fjl fjl closed this as completed in ec53cec Apr 3, 2017
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