| 109 | } |
| 110 | |
| 111 | func (p *OperatorOverloading) Check() { |
| 112 | for _, fn := range p.Overloads { |
| 113 | fnType, foundType := p.Env.Get(p.NtCache, fn) |
| 114 | fnFunc, foundFunc := p.Functions[fn] |
| 115 | if !foundFunc && (!foundType || fnType.Type.Kind() != reflect.Func) { |
| 116 | panic(fmt.Errorf("function %s for %s operator does not exist in the environment", fn, p.Operator)) |
| 117 | } |
| 118 | |
| 119 | if foundType { |
| 120 | checkType(fnType, fn, p.Operator) |
| 121 | } |
| 122 | |
| 123 | if foundFunc { |
| 124 | checkFunc(fnFunc, fn, p.Operator) |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | func checkType(fnType nature.Nature, fn string, operator string) { |
| 130 | requiredNumIn := 2 |