Skip to content

Commit

Permalink
fix: handle nil in walker instead as this applies more broadly
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarm committed Mar 1, 2024
1 parent 114cf34 commit 4b50888
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 1 addition & 3 deletions hclsyntax/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -1133,9 +1133,7 @@ type TupleConsExpr struct {

func (e *TupleConsExpr) walkChildNodes(w internalWalkFunc) {
for _, expr := range e.Exprs {
if expr != nil {
w(expr)
}
w(expr)
}
}

Expand Down
5 changes: 5 additions & 0 deletions hclsyntax/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ type Walker interface {
// node, which provides information about the tree structure via separate
// Enter and Exit functions.
func Walk(node Node, w Walker) hcl.Diagnostics {
// nothing to walk into
if node == nil {
return nil
}

diags := w.Enter(node)
node.walkChildNodes(func(node Node) {
diags = append(diags, Walk(node, w)...)
Expand Down

0 comments on commit 4b50888

Please sign in to comment.