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

Don't crash when using Infinity or NaN as a key in a map #1073

Merged
merged 2 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

* Don't crash when writing `Infinity` in JS mode.

* Don't crash when using `Infinity` or `NaN` as a key in a map.

## 1.26.10

* Fixes a bug where two adjacent combinators could cause an error.
Expand Down
4 changes: 3 additions & 1 deletion lib/src/util/number.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ bool fuzzyEquals(num number1, num number2) =>
final _inverseEpsilon = 1 / epsilon;

/// Returns a hash code for [number] that matches [fuzzyEquals].
int fuzzyHashCode(num number) => (number * _inverseEpsilon).round().hashCode;
int fuzzyHashCode(num number) => number.isInfinite || number.isNaN
? number.hashCode
: (number * _inverseEpsilon).round().hashCode;

/// Returns whether [number1] is less than [number2], and not [fuzzyEquals].
bool fuzzyLessThan(num number1, num number2) =>
Expand Down