about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--032array.cc11
-rw-r--r--055shape_shifting_container.cc20
2 files changed, 22 insertions, 9 deletions
diff --git a/032array.cc b/032array.cc
index 64264ef8..7c134bdb 100644
--- a/032array.cc
+++ b/032array.cc
@@ -269,6 +269,17 @@ void test_container_sizes_from_repeated_address_and_array_types() {
   CHECK_EQ(SIZE(Container_metadata)-old_size, 1);
 }
 
+void test_container_sizes_on_unknown_type() {
+  // a container we don't have the size for
+  reagent container("x:point");
+  int old_size = SIZE(Container_metadata);
+  // scanning address to array with a typo
+  reagent r("x:address:array:adress:number");
+  compute_container_sizes(r, "");  // should not crash
+  // no non-container types precomputed
+  CHECK_EQ(SIZE(Container_metadata), old_size);
+}
+
 //:: To access elements of an array, use 'index'
 
 :(scenario index)
diff --git a/055shape_shifting_container.cc b/055shape_shifting_container.cc
index 6083f904..a9225960 100644
--- a/055shape_shifting_container.cc
+++ b/055shape_shifting_container.cc
@@ -555,15 +555,17 @@ def main [
 
 :(before "End compute_container_sizes Non-atom Special-cases")
 const type_tree* root = get_base_type(type);
-type_info& info = get(Type, root->value);
-if (info.kind == CONTAINER) {
-  compute_container_sizes(info, type, pending_metadata, location_for_error_messages);
-  return;
-}
-if (info.kind == EXCLUSIVE_CONTAINER) {
-  compute_exclusive_container_sizes(info, type, pending_metadata, location_for_error_messages);
-  return;
-}
+if (contains_key(Type, root->value)) {
+  type_info& info = get(Type, root->value);
+  if (info.kind == CONTAINER) {
+    compute_container_sizes(info, type, pending_metadata, location_for_error_messages);
+    return;
+  }
+  if (info.kind == EXCLUSIVE_CONTAINER) {
+    compute_exclusive_container_sizes(info, type, pending_metadata, location_for_error_messages);
+    return;
+  }
+}  // otherwise error raised elsewhere
 
 :(before "End Unit Tests")
 void test_container_sizes_shape_shifting_container() {