From a458a390e2cd9c15d9f415954e50ce2ed1bbb81f Mon Sep 17 00:00:00 2001 From: vddCore Date: Tue, 14 Nov 2023 15:50:05 +0100 Subject: [PATCH] return nil when overflow or format of a number are incorrect. --- .../DynamicValueOperations.Conversion.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/VirtualMachine/Ceres/ExecutionEngine/TypeSystem/DynamicValueOperations.Conversion.cs b/VirtualMachine/Ceres/ExecutionEngine/TypeSystem/DynamicValueOperations.Conversion.cs index cbad7591..026a8557 100644 --- a/VirtualMachine/Ceres/ExecutionEngine/TypeSystem/DynamicValueOperations.Conversion.cs +++ b/VirtualMachine/Ceres/ExecutionEngine/TypeSystem/DynamicValueOperations.Conversion.cs @@ -66,11 +66,19 @@ public static DynamicValue ConvertToNumber(this DynamicValue a) { return double.Parse(a.String!); } - catch (FormatException fe) + catch (FormatException) + { + return DynamicValue.Nil; + } + catch (OverflowException) + { + return DynamicValue.Nil; + } + catch (Exception e) { throw new MalformedNumberException( - $"Attempt to convert '{a.String}' to a number.", - fe + $"Attempt to convert '{a.String}' to a Number.", + e ); } }