clarkmcc / cel-rust

Common Expression Language interpreter written in Rust
https://crates.io/crates/cel-interpreter
MIT License
362 stars 18 forks source link

Support indexing maps with any valid key type #36

Closed fore5fire closed 6 months ago

fore5fire commented 7 months ago

According to the spec, maps should support int, uint, and bool keys in addition to strings. The parser already supports this but accessing maps using non-string keys is unimplemented in the interpreter, so I added match cases to support this.

The spec makes it pretty clear that map indexes of ints, uints, and floats are done using the cel's numeric equality (see https://github.com/google/cel-spec/blob/master/doc/langdef.md#equality and https://github.com/google/cel-spec/blob/master/doc/langdef.md#numbers). For statically typed maps this would be rejected by the checker even though its allowed by the runtime, but from what I can tell cel-rust doesn't have a separate check step, so I implemented these to work how spec describes the runtime.

clarkmcc commented 6 months ago

@fore5fire approved but looks like there are conflicts that need to be resolved.

fore5fire commented 6 months ago

@fore5fire approved but looks like there are conflicts that need to be resolved.

Should be fixed now