Fix index exception when setting empty Tree slice (#425)

This commit is contained in:
Stephen Levine
2020-09-10 21:19:18 -04:00
committed by GitHub
parent 661484ae7e
commit 9f8f82dfe8
+2 -1
View File
@@ -339,7 +339,8 @@ func (t *Tree) SetPathWithOptions(keys []string, opts SetOptions, value interfac
// go to most recent element // go to most recent element
if len(node) == 0 { if len(node) == 0 {
// create element if it does not exist // 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] subtree = node[len(node)-1]
} }