From f9c163e5570ee42907aaad4695530547b82a5c0b Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Wed, 19 Aug 2020 20:04:20 -0400 Subject: [PATCH] no longer panic on unimplemented division not implemented, but makes fuzzing less noisy --- src/parse/value/eval.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/parse/value/eval.rs b/src/parse/value/eval.rs index af47dbf..0034f63 100644 --- a/src/parse/value/eval.rs +++ b/src/parse/value/eval.rs @@ -499,6 +499,11 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> { return Ok(Value::Dimension(None, Unit::None, true)); } + if num2.is_zero() { + // todo: Infinity and -Infinity + return Err(("Infinity not yet implemented.", self.span).into()); + } + // `unit(1em / 1em)` => `""` if unit == unit2 { Value::Dimension(Some(num / num2), Unit::None, true) @@ -523,7 +528,12 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> { // within the `Value` enum } else { // todo: remember to account for `Mul` and `Div` - todo!("non-comparable inverse units") + // todo!("non-comparable inverse units") + return Err(( + "Division of non-comparable units not yet supported.", + self.span, + ) + .into()); } } else { Value::String(