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

This does not parse, while being toml v0.4.0 compliant. #7

Closed
evertheylen opened this issue Jul 9, 2015 · 0 comments
Closed

This does not parse, while being toml v0.4.0 compliant. #7

evertheylen opened this issue Jul 9, 2015 · 0 comments

Comments

@evertheylen
Copy link

This does not parse, and it should, according to the spec.

[irc_servers]
    freenode = "chat.freenode.net:8001"
    quakenet = "irc.quakenet.org:6667"

[users]
    [users.alice]
        nick = "tester_Alice"
        name = "Alice"
        channels = {freenode = ["#test123456", "#test1234567"], quakenet = ["#xonotic"]}

    [users.bob]
        nick = "tester_Bob"
        name = "Bob"
        channels = {freenode = ["#test123456"], quakenet = ["#xonotic", "#quake"]}

I have also tested this with https://github.com/avakar/pytoml, which can parse this without problems.

I use these structs:

type TomlUser struct {
    Nick string
    Name string
    Channels map[string][]string
}

type TomlConfig struct {
    IrcServers map[string]string
    Users map[string]TomlUser
}

Full example program: http://play.golang.org/p/-qWU5Y0RW-

Gives me this error:

panic: toml:http://play.golang.org/p/aeGl88Vog5

goroutine 1 [running]:
main.main()
        /tmp/test/marshltest.go:40 +0xdf

goroutine 5 [chan send]:
github.com/naoina/toml.(*tokens16).Tokens.func1(0xc82001a300, 0xc8200d8000)
        /Bestanden/Arch/Go/src/github.com/naoina/toml/parse.peg.go:466 +0x134
created by github.com/naoina/toml.(*tokens16).Tokens
        /Bestanden/Arch/Go/src/github.com/naoina/toml/parse.peg.go:469 +0x5d
exit status 2

If I replace map[string]string with []string it does work: http://play.golang.org/p/mtLIcqURv5.

kezhuw added a commit to kezhuw/naoina-toml that referenced this issue Dec 25, 2015
kezhuw added a commit to kezhuw/naoina-toml that referenced this issue Dec 27, 2015
The old global table name mapping method is an special cases handling.
It is fragile and was broken in cases where inline tables were defined.
Inline tables which have no parents names in their name path escaped their
names to global table name map in old code. Following is a example:

```toml
[[servers]]
listen = { port = 1234 }  # "listen" escapes to global table name map
[[servers]]
listen = { port = 2345 }  # conflicts with previously escaped name "listen"
```

Fixes naoina#7.
@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

1 participant