| 603 | } |
| 604 | |
| 605 | func (v *Checker) sliceNode(node *ast.SliceNode) Nature { |
| 606 | nt := v.visit(node.Node) |
| 607 | |
| 608 | if nt.IsUnknown(&v.config.NtCache) { |
| 609 | return Nature{} |
| 610 | } |
| 611 | |
| 612 | switch nt.Kind { |
| 613 | case reflect.String, reflect.Array, reflect.Slice: |
| 614 | // ok |
| 615 | default: |
| 616 | return v.error(node, "cannot slice %s", nt.String()) |
| 617 | } |
| 618 | |
| 619 | if node.From != nil { |
| 620 | from := v.visit(node.From) |
| 621 | from = from.Deref(&v.config.NtCache) |
| 622 | if !from.IsInteger && !from.IsUnknown(&v.config.NtCache) { |
| 623 | return v.error(node.From, "non-integer slice index %v", from.String()) |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | if node.To != nil { |
| 628 | to := v.visit(node.To) |
| 629 | to = to.Deref(&v.config.NtCache) |
| 630 | if !to.IsInteger && !to.IsUnknown(&v.config.NtCache) { |
| 631 | return v.error(node.To, "non-integer slice index %v", to.String()) |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | return nt |
| 636 | } |
| 637 | |
| 638 | func (v *Checker) callNode(node *ast.CallNode) Nature { |
| 639 | // Check if type was set on node (for example, by patcher) |