-
Notifications
You must be signed in to change notification settings - Fork 220
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
Unify overflow checking in operators, field setting #448
Unify overflow checking in operators, field setting #448
Conversation
} | ||
|
||
// Nanoseconds cannot overflow as time.Time normalizes them to [0, 999999999]. | ||
nsec := nsec1 - nsec2 | ||
|
||
// We need to normalize nanoseconds to be positive and carry extra nanoseconds to seconds. |
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.
Note, the nanos are properly normalized in this case, so the logic ported from time.Unix
was redundant and removed.
@@ -127,17 +126,17 @@ func (d Double) ConvertToNative(typeDesc reflect.Type) (interface{}, error) { | |||
func (d Double) ConvertToType(typeVal ref.Type) ref.Val { | |||
switch typeVal { | |||
case IntType: | |||
i := math.Round(float64(d)) |
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.
The removal of the rounding behavior on conversion is expected and part of a cel-spec update.
89776ff
to
89b880d
Compare
a094760
to
e277d68
Compare
This PR consolidates additional overflow checks into
overflow.go
and ensures they are applied consistently when setting object field values.There are some extensive test refactors and an update to the latest version of cel-spec v0.6.0 as well to ensure that the new code paths are being exercised and that the changes adhere to the spec. As part of this change, a small set of conformance tests now check for value truncation (rather than rounding) when converting from floating point to integer values. Given that the fixes for the incoming spec behavior were small, the truncation change was also made as part of this PR.