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

panic unmarshaling array of tables #839

Open
jmank88 opened this issue Jan 20, 2023 · 3 comments
Open

panic unmarshaling array of tables #839

jmank88 opened this issue Jan 20, 2023 · 3 comments
Labels
bug Issues describing a bug in go-toml.

Comments

@jmank88
Copy link
Contributor

jmank88 commented Jan 20, 2023

Describe the bug
Unmarshaling to a field of a table in an array of tables causes a panic.

To Reproduce
https://go.dev/play/p/l2KDjY4lX-3

m := struct {
	A []struct {
		B struct{}
	}
}{}
fmt.Println(toml.Unmarshal([]byte(`[[A.B]]`), &m))

Expected behavior
If this is invalid, I expect an error rather than a panic.

Versions

  • go-toml: 2.0.6
  • go: 1.19
  • operating system: Linux, Go-playground
@pelletier pelletier added the bug Issues describing a bug in go-toml. label Feb 1, 2023
@pelletier
Copy link
Owner

Thank you for the bug report! I'll take a look when I have time, but feel free to send a pull request in the meantime!

@jmank88
Copy link
Contributor Author

jmank88 commented Feb 4, 2023

@pelletier I started a draft that highlights the problematic area (#840). Is returning an error the correct thing to do here?

@pelletier
Copy link
Owner

You're correct: this should be an error, because the array of tables is on A.B, and B is a struct, not a slice.

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.
Projects
None yet
Development

No branches or pull requests

2 participants