fix(parser): reset dotted-key and array records per array-of-tables element
Assisted-by: GLM 5.3
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user