Skip to content

Commit f4c4daa

Browse files
committed
Changed the location of the case closer to similar case
1 parent 3dd1004 commit f4c4daa

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

go/analysis/passes/nilness/nilness.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func (n nilness) String() string { return nilnessStrings[n+1] }
245245
// or unknown given the dominating stack of facts.
246246
func nilnessOf(stack []fact, v ssa.Value) nilness {
247247
switch v := v.(type) {
248-
// unwrap ChangeInterface values recursively, to detect if underlying
248+
// unwrap ChangeInterface and Slice values recursively, to detect if underlying
249249
// values have any facts recorded or are otherwise known with regard to nilness.
250250
//
251251
// This work must be in addition to expanding facts about
@@ -259,6 +259,10 @@ func nilnessOf(stack []fact, v ssa.Value) nilness {
259259
if underlying := nilnessOf(stack, v.X); underlying != unknown {
260260
return underlying
261261
}
262+
case *ssa.Slice:
263+
if underlying := nilnessOf(stack, v.X); underlying != unknown {
264+
return underlying
265+
}
262266
}
263267

264268
// Is value intrinsically nil or non-nil?
@@ -275,12 +279,6 @@ func nilnessOf(stack []fact, v ssa.Value) nilness {
275279
*ssa.MakeMap,
276280
*ssa.MakeSlice:
277281
return isnonnil
278-
case *ssa.Slice:
279-
// unwrap Slice values recursively, to detect if underlying
280-
// values have any facts recorded or are otherwise known with regard to nilness.
281-
if underlying := nilnessOf(stack, v.X); underlying != unknown {
282-
return underlying
283-
}
284282
case *ssa.Const:
285283
if v.IsNil() {
286284
return isnil

0 commit comments

Comments
 (0)