Commit activity
Last 12 weeks · 0 commits
Community health
3 of 6 standards met
Recent PRs & issues
Missing and stray commas in inline tables from eStruct and eMap** The separator is placed from the struct field index or the map key position, but direct entries are written before sub-tables and nil values are skipped, so inside an array encodes as (#530), which the decoder rejects, and a nil pointer or nil map value sorted last leaves . The comma is now written before each entry actually emitted after the first, in both the struct and map paths; the three new TestEncode cases fail on master and pass with this change.
unifyMap tests after the failed type assertion, but tmap is always nil at that point, so the badtype error below is unreachable and decoding or into a field returns no error and leaves an empty map. The same mismatch into a struct or slice already errors. Check instead, as unifyStruct does, so only a genuinely absent value is skipped. The two new TestDecodeErrors cases fail with "err is nil" on master and pass with this change.
Recent fixes
Fixes #470 Problem Per the TOML specification, once a key is defined as an inline table, array, or concrete value, adding subkeys to it (such as or or ) is invalid. In , marked intermediate key parts as implicit without checking if the key had already been concretely defined, allowing invalid subkey definitions to pass. Solution Check existing key definition state before marking implicit context. If the target parent key has already been concretely defined as a non-table or existing table, reject the addition of subkeys with a parse error. Testing Added regression tests in for , , and . Verified all valid TOML tests and test suites pass 100% with race detector enabled.
Problem When encoding structs as inline tables, splits struct fields into and . Inside , trailing commas were determined by comparing the struct definition index with : This caused two bugs: 1. If direct and sub-table fields are interleaved (for example, struct fields , , ), contains indices 0 and 2 while contains index 1. When writing field , , skipping the comma separator before . When writing field , , emitting an invalid trailing comma. 2. If fields are omitted due to , , or nil values, does not match the actual count of written fields, producing invalid trailing commas. had a similar issue by relying on key slice indexing rather than whether fields were emitted. Solution Track emitted fields in and with a shared boolean flag across direct and sub-field passes. Prepend before writing any field after the first emitted field when is true. Fixes #530.
Fixes #451 When a table ancestor is created implicitly (such as in ), the parser marked it as implicit to allow defining it as an explicit table later. If the ancestor was subsequently reassigned as a primitive scalar value, array, or conflicting type (such as ), cleared the implicit marker and returned without modifying the table or reporting an error. This change verifies that concrete assignments targeting implicit keys are valid tables before removing the implicit status. If an implicit ancestor is redefined as a non-table value, or if an existing table/array of tables has an invalid type conflict, the parser reports a duplicate key definition error.
Repository: BurntSushi/toml. Description: TOML parser for Golang with reflection. Stars: 5033, Forks: 624. Primary language: Go. Languages: Go (100%). License: MIT. Latest release: v1.6.0 (11mo ago). Open PRs: 10, open issues: 20. Last activity: 2mo ago. Community health: 57%. Top contributors: arp242, BurntSushi, cespare, sqs, kkHAIKE, rjeczalik, ttacon, spf13, sahvx655-wq, martinlindhe and others.