File tree 2 files changed +5
-4
lines changed
go/analysis/passes/nilness
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -276,10 +276,11 @@ func nilnessOf(stack []fact, v ssa.Value) nilness {
276
276
* ssa.MakeSlice :
277
277
return isnonnil
278
278
case * ssa.Slice :
279
- if cons , ok := v .X .(* ssa.Const ); ok && cons .IsNil () {
280
- return isnil
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
281
283
}
282
- return isnonnil
283
284
case * ssa.Const :
284
285
if v .IsNil () {
285
286
return isnil
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ func f10() {
164
164
if s1 == nil { // want "tautological condition: nil == nil"
165
165
print (0 )
166
166
}
167
- s2 := s1 [:]
167
+ s2 := s1 [:][:]
168
168
if s2 == nil { // want "tautological condition: nil == nil"
169
169
print (0 )
170
170
}
You can’t perform that action at this time.
0 commit comments