(name string, fn func(x, y int) (any, error))
| 69 | } |
| 70 | |
| 71 | func bitFunc(name string, fn func(x, y int) (any, error)) *Function { |
| 72 | return &Function{ |
| 73 | Name: name, |
| 74 | Func: func(args ...any) (any, error) { |
| 75 | if len(args) != 2 { |
| 76 | return nil, fmt.Errorf("invalid number of arguments for %s (expected 2, got %d)", name, len(args)) |
| 77 | } |
| 78 | x, err := toInt(args[0]) |
| 79 | if err != nil { |
| 80 | return nil, fmt.Errorf("%v to call %s", err, name) |
| 81 | } |
| 82 | y, err := toInt(args[1]) |
| 83 | if err != nil { |
| 84 | return nil, fmt.Errorf("%v to call %s", err, name) |
| 85 | } |
| 86 | return fn(x, y) |
| 87 | }, |
| 88 | Types: types(new(func(int, int) int)), |
| 89 | } |
| 90 | } |
no test coverage detected
searching dependent graphs…