Skip to content

Commit 300197c

Browse files
authored
Don't crash when using Infinity or NaN as a key in a map (#1073)
Closes #3126
1 parent c4f95d4 commit 300197c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* **Potentially breaking bug fix:** `meta.load-css()` now correctly uses the
44
name `$url` for its first argument, rather than `$module`.
55

6+
* Don't crash when using `Infinity` or `NaN` as a key in a map.
7+
68
* Emit a proper parse error for a `=` with no right-hand side in a function.
79

810
## 1.27.0

lib/src/util/number.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ bool fuzzyEquals(num number1, num number2) =>
1919
final _inverseEpsilon = 1 / epsilon;
2020

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

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

0 commit comments

Comments
 (0)