MCPcopy Index your code
hub / github.com/expr-lang/expr / bitFunc

Function bitFunc

builtin/utils.go:71–90  ·  view source on GitHub ↗
(name string, fn func(x, y int) (any, error))

Source from the content-addressed store, hash-verified

69}
70
71func 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}

Callers 1

builtin.goFile · 0.85

Calls 4

toIntFunction · 0.85
fnFuncType · 0.85
typesFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…