MCPcopy Index your code
hub / github.com/coder/coder / Array

Function Array

coderd/rbac/regosql/sqltypes/array.go:18–26  ·  view source on GitHub ↗

Array is typed to whatever the first element is. If there is not first element, the array element type is invalid.

(source RegoSource, nodes ...Node)

Source from the content-addressed store, hash-verified

16// Array is typed to whatever the first element is. If there is not first
17// element, the array element type is invalid.
18func Array(source RegoSource, nodes ...Node) (Node, error) {
19 for i := 1; i < len(nodes); i++ {
20 if reflect.TypeOf(nodes[0]) != reflect.TypeOf(nodes[i]) {
21 // Do not allow mixed types in arrays
22 return nil, xerrors.Errorf("array element %d in %q: type mismatch", i, source)
23 }
24 }
25 return ASTArray{Value: nodes, Source: source}, nil
26}
27
28func (ASTArray) UseAs() Node { return ASTArray{} }
29

Callers 6

convertTermFunction · 0.92
TestEqualityFunction · 0.92
TestMembershipFunction · 0.92
XGridFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by 2

TestEqualityFunction · 0.74
TestMembershipFunction · 0.74