-
Notifications
You must be signed in to change notification settings - Fork 258
Open
Description
Change
Today it is not possible to add a variable that is contained in the following list:
stdTypes = []*decls.VariableDecl{
decls.TypeVariable(types.BoolType),
decls.TypeVariable(types.BytesType),
decls.TypeVariable(types.DoubleType),
decls.TypeVariable(types.DurationType),
decls.TypeVariable(types.IntType),
decls.TypeVariable(listOfA),
decls.TypeVariable(mapOfAB),
decls.TypeVariable(types.NullType),
decls.TypeVariable(types.StringType),
decls.TypeVariable(types.TimestampType),
decls.TypeVariable(types.TypeType),
decls.TypeVariable(types.UintType),
}
It could have been nice to allow, for example, adding type as a variable - it should work since if it is not used as a function type() CEL knows to differentiate between the two.
Example
type == 'my-variable'
Alternatives considered
- Use
NewCustomEnv- I tried this, but this was very complicated since it disabled many functions such as_==_for all types. I basically just want to free the above types as variables. - Use
//go:linkname stdTypes github.com/google/cel-go/common/stdlib.stdTypesand set it to an empty liststdTypes = []*decls.VariableDecl{}- this works but affects all CEL usages and generally should be avoided.
Metadata
Metadata
Assignees
Labels
No labels