(node *ast.UnaryNode)
| 289 | } |
| 290 | |
| 291 | func (v *Checker) unaryNode(node *ast.UnaryNode) Nature { |
| 292 | nt := v.visit(node.Node) |
| 293 | nt = nt.Deref(&v.config.NtCache) |
| 294 | |
| 295 | switch node.Operator { |
| 296 | |
| 297 | case "!", "not": |
| 298 | if nt.IsBool() { |
| 299 | return v.config.NtCache.FromType(boolType) |
| 300 | } |
| 301 | if nt.IsUnknown(&v.config.NtCache) { |
| 302 | return v.config.NtCache.FromType(boolType) |
| 303 | } |
| 304 | |
| 305 | case "+", "-": |
| 306 | if nt.IsNumber() { |
| 307 | return nt |
| 308 | } |
| 309 | if nt.IsUnknown(&v.config.NtCache) { |
| 310 | return Nature{} |
| 311 | } |
| 312 | |
| 313 | default: |
| 314 | return v.error(node, "unknown operator (%s)", node.Operator) |
| 315 | } |
| 316 | |
| 317 | return v.error(node, `invalid operation: %s (mismatched type %s)`, node.Operator, nt.String()) |
| 318 | } |
| 319 | |
| 320 | func (v *Checker) binaryNode(node *ast.BinaryNode) Nature { |
| 321 | l := v.visit(node.Left) |
no test coverage detected