From 675b517274b8c912df04b9f304947ce47201da8f Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Tue, 29 Aug 2017 14:56:12 -0700 Subject: [PATCH] Fix some incorrect checks for Array property types --- src/js_types.hpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/js_types.hpp b/src/js_types.hpp index dce8140c..ec89adff 100644 --- a/src/js_types.hpp +++ b/src/js_types.hpp @@ -364,14 +364,10 @@ inline bool Value::is_valid_for_property(ContextType context, const ValueType } else if (prop.type == PropertyType::LinkingObjects) { return false; } - else if (prop.type == PropertyType::Array) { - return true; - } return false; } - using PropertyType = realm::PropertyType; switch (prop.type & ~PropertyType::Flags) { case PropertyType::Int: case PropertyType::Float: @@ -389,10 +385,9 @@ inline bool Value::is_valid_for_property(ContextType context, const ValueType return true; case PropertyType::Any: return false; + default: + REALM_UNREACHABLE(); } - - REALM_UNREACHABLE(); - return false; } inline std::string js_type_name_for_property_type(PropertyType type) @@ -401,12 +396,10 @@ inline std::string js_type_name_for_property_type(PropertyType type) if (type == PropertyType::LinkingObjects) { throw std::runtime_error("LinkingObjects' type is not supported"); } - else if (type == PropertyType::Array) { - return "array"; - } - } + return "array"; + } - switch (type) { + switch (type & ~PropertyType::Flags) { case PropertyType::Int: case PropertyType::Float: case PropertyType::Double: @@ -423,10 +416,9 @@ inline std::string js_type_name_for_property_type(PropertyType type) return "object"; case PropertyType::Any: throw std::runtime_error("'Any' type is not supported"); + default: + REALM_UNREACHABLE(); } - - REALM_UNREACHABLE(); - return ""; } } // js