Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions build/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,12 +1032,19 @@ func (p *printer) useCompactMode(start *Position, list *[]Expr, end *End, mode s
// If multiLine is true, seq avoids the compact form even
// for 0- and 1-element sequences.
func (p *printer) seq(brack string, start *Position, list *[]Expr, end *End, mode seqMode, forceCompact, forceMultiLine bool) {
args := &[]Expr{}
for _, x := range *list {
// nil arguments may be added by some linter checks, filter them out because
// they may cause NPE.
if x != nil {
*args = append(*args, x)
// Filter out nil arguments (rare; added by some linter checks) that may cause a NPE, copying only if needed.
args := list
for i, x := range *list {
if x == nil {
filtered := make([]Expr, i, len(*list))
copy(filtered, (*list)[:i])
for _, y := range (*list)[i+1:] {
if y != nil {
filtered = append(filtered, y)
}
}
args = &filtered
break
}
}
Comment thread
jbedard marked this conversation as resolved.

Expand Down