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 all commits
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 @@ -3,6 +3,8 @@
* **Potentially breaking bug fix:** `meta.load-css()` now correctly uses the
name `$url` for its first argument, rather than `$module`.

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

* Emit a proper parse error for a `=` with no right-hand side in a function.

## 1.27.0
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