-
Notifications
You must be signed in to change notification settings - Fork 3
Generate enums for operators and overloads #243
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
base: main
Are you sure you want to change the base?
Conversation
packages/cel/src/func.ts
Outdated
| ): CelOverload<P, R> { | ||
| return new FuncOverload(parameters, result, impl); | ||
| return new FuncOverload( | ||
| crypto.randomUUID(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like crypto is safe to use everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Widely available" according to mdn. Safe to use. https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID
packages/cel/src/type.ts
Outdated
| /** | ||
| * Returns true if the given value is a numeric CelType. | ||
| */ | ||
| export function isCelNumericType( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that this is only used in tests can we move this to the test file?
|
Mostly superseded by #244, but some automation is probably worth keeping. |
483c511 to
2026e55
Compare
Random overload IDsAfter staring at the schema I'm proposing that we generate UUIDs for
overload_idvalues at compile time.It basically seems like a bug to me that other implementations treat these as non-opaque values when their stated purpose is purely for cross-referencing values in a compiled expression payload. Using non-opaque IDs, let alone specific, stable non-opaque IDs does not seem to be part of the contract.And I believe it should be avoided because of the potential for unintentional collisions that could cause subtle-but-nasty bugs. The best way to avoid depending on the semantics or stability of values is to randomize them.Cross-type numeric comparisonsWhere we need to treat specific overloads specially, I have instead proposed a mechanism for standardized flags, and added
CelOverloadFlag.CROSS_TYPE_NUMERIC_COMPARISONas the inaugural flag. I've also added a syntheticisCrossTypeNumericComparisonproperty to overloads and a test to verify that the overloads — and only those overloads — that we expect to returntruefor this property do so.Stale generated files
The
operator_const.tsandoverload_const.tsfiles were previously generated... but generated from some hand-maintained YAML files? The generation mechanism and source YAML files have been lost in refactors.I've added code that generates these from
cel-goto thecel-specbuild, and now import these enumerations from that package.