fix(parser): reset dotted-key and array records per array-of-tables element

Assisted-by: GLM 5.3
This commit is contained in:
2026-09-17 23:05:06 +02:00
parent 696f117c22
commit 830f840f44
3 changed files with 43 additions and 10 deletions
+9 -10
View File
@@ -274,18 +274,17 @@ func (p *parser) freezeInline(path []string, val any) {
}
}
// resetScopeUnder forgets the header and freeze records nested under key, which
// belong to the previous element of an array of tables.
// resetScopeUnder forgets the definition records nested under key, which
// belong to the previous element of an array of tables: headers, frozen
// inline tables, dotted-key paths, and nested arrays of tables all start
// fresh in the new element.
func (p *parser) resetScopeUnder(key []string) {
prefix := pathKey(key) + "\x00"
for k := range p.headers {
if strings.HasPrefix(k, prefix) {
delete(p.headers, k)
}
}
for k := range p.frozen {
if strings.HasPrefix(k, prefix) {
delete(p.frozen, k)
for _, m := range []map[string]bool{p.headers, p.frozen, p.dotted, p.arrays} {
for k := range m {
if strings.HasPrefix(k, prefix) {
delete(m, k)
}
}
}
}