Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support indexing maps with any valid key type #36

Merged
merged 4 commits into from
Feb 26, 2024

Conversation

fore5fire
Copy link
Contributor

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.

Copy link
Owner

@clarkmcc clarkmcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

@clarkmcc
Copy link
Owner

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

@fore5fire
Copy link
Contributor Author

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

Should be fixed now

@clarkmcc clarkmcc merged commit 458c313 into clarkmcc:master Feb 26, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants