From a12a8b02f651fc81fe6aabd1ae17edd62230f0be Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Sun, 17 Dec 2023 13:06:10 +0200 Subject: [PATCH] Assert only -0 being an acceptable Value::Float PropertyKey --- .../types/language/object/property_key.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nova_vm/src/ecmascript/types/language/object/property_key.rs b/nova_vm/src/ecmascript/types/language/object/property_key.rs index 22517ac3c..7bf895520 100644 --- a/nova_vm/src/ecmascript/types/language/object/property_key.rs +++ b/nova_vm/src/ecmascript/types/language/object/property_key.rs @@ -122,13 +122,13 @@ impl TryFrom for PropertyKey { fn try_from(value: Value) -> Result { match value { Value::Integer(x) => Ok(PropertyKey::Integer(x)), - Value::Float(x) - if x.fract() == 0.0 - && (SmallInteger::MIN_NUMBER..=SmallInteger::MAX_NUMBER) - .contains(&(x as i64)) => - { - if let Ok(x) = SmallInteger::try_from(x as i64) { - Ok(PropertyKey::Integer(x)) + Value::Float(x) => { + if x == -0.0f32 { + Ok(PropertyKey::Integer(0)) + } else if x.fract() == 0.0 + && (SmallInteger::MIN_NUMBER..=SmallInteger::MAX_NUMBER).contains(&(x as i64)) + { + unreachable!("Value::Float should not contain safe integers"); } else { Err(()) }