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

Return Error If Overflow #686

Merged
merged 3 commits into from Jul 29, 2022
Merged

Conversation

YoshikiTakashima
Copy link
Contributor

Fixes #682 by allowing i64 wrapping during negation.

This allows seconds = i64::MIN to pass with debug checks enabled.

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

I wonder if we should actually return an error rather than wrapping. What do you think?

@YoshikiTakashima
Copy link
Contributor Author

YoshikiTakashima commented Jul 29, 2022

So with seconds = i64::min, the function already returns TimestampError::OutOfSystemRange(orig_timestamp).

I also made one that makes this error return more explicit, although it's much more verbose.

Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

@LucioFranco LucioFranco merged commit 6c2c75a into tokio-rs:master Jul 29, 2022
@YoshikiTakashima YoshikiTakashima changed the title Permit overflow with wrapping. Return Error If Overflow Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants