Skip to content

Commit

Permalink
Fix index exception when setting empty Tree slice (#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
sclevine authored Sep 11, 2020
1 parent 661484a commit 9f8f82d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ func (t *Tree) SetPathWithOptions(keys []string, opts SetOptions, value interfac
// go to most recent element
if len(node) == 0 {
// create element if it does not exist
subtree.values[intermediateKey] = append(node, newTreeWithPosition(Position{Line: t.position.Line + i, Col: t.position.Col}))
node = append(node, newTreeWithPosition(Position{Line: t.position.Line + i, Col: t.position.Col}))
subtree.values[intermediateKey] = node
}
subtree = node[len(node)-1]
}
Expand Down

0 comments on commit 9f8f82d

Please sign in to comment.