(node *ast.ConditionalNode)
| 1281 | } |
| 1282 | |
| 1283 | func (v *Checker) conditionalNode(node *ast.ConditionalNode) Nature { |
| 1284 | c := v.visit(node.Cond) |
| 1285 | c = c.Deref(&v.config.NtCache) |
| 1286 | if !c.IsBool() && !c.IsUnknown(&v.config.NtCache) { |
| 1287 | return v.error(node.Cond, "non-bool expression (type %v) used as condition", c.String()) |
| 1288 | } |
| 1289 | |
| 1290 | t1 := v.visit(node.Exp1) |
| 1291 | t2 := v.visit(node.Exp2) |
| 1292 | |
| 1293 | if t1.Nil && !t2.Nil { |
| 1294 | return t2 |
| 1295 | } |
| 1296 | if !t1.Nil && t2.Nil { |
| 1297 | return t1 |
| 1298 | } |
| 1299 | if t1.Nil && t2.Nil { |
| 1300 | return v.config.NtCache.NatureOf(nil) |
| 1301 | } |
| 1302 | if t1.AssignableTo(t2) { |
| 1303 | if t1.IsArray() && t2.IsArray() { |
| 1304 | e1 := t1.Elem(&v.config.NtCache) |
| 1305 | e2 := t2.Elem(&v.config.NtCache) |
| 1306 | if !e1.AssignableTo(e2) || !e2.AssignableTo(e1) { |
| 1307 | return v.config.NtCache.FromType(arrayType) |
| 1308 | } |
| 1309 | } |
| 1310 | return t1 |
| 1311 | } |
| 1312 | return Nature{} |
| 1313 | } |
| 1314 | |
| 1315 | func (v *Checker) arrayNode(node *ast.ArrayNode) Nature { |
| 1316 | var prev Nature |
no test coverage detected