Skip to content

Commit a6387e0

Browse files
authored
Merge pull request #890 from google/gosec-is-dumb
chore: reformat ast mergepositionlist because gosec is buggy
2 parents 8d2101c + 85de4e1 commit a6387e0

File tree

1 file changed

+8
-7
lines changed
  • internal/runtime/compiler/ast

1 file changed

+8
-7
lines changed

internal/runtime/compiler/ast/ast.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,15 @@ func (n *StopStmt) Type() types.Type {
435435

436436
// mergepositionlist is a helper that merges the positions of all the nodes in a list.
437437
func mergepositionlist(l []Node) *position.Position {
438-
if len(l) == 0 {
438+
switch len(l) {
439+
case 0:
439440
return nil
440-
}
441-
if len(l) == 1 {
442-
if l[0] != nil {
443-
return l[0].Pos()
441+
case 1:
442+
if l[0] == nil {
443+
return nil
444444
}
445-
return nil
445+
return l[0].Pos()
446+
default:
447+
return position.Merge(l[0].Pos(), mergepositionlist(l[1:]))
446448
}
447-
return position.Merge(l[0].Pos(), mergepositionlist(l[1:]))
448449
}

0 commit comments

Comments
 (0)