about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-07-24 01:12:20 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-07-24 01:13:53 -0700
commite689294c4b1d3b256a0958070948fa146182cfc1 (patch)
tree8f27b111891eced46c9ea47965d1c0aba83f5483
parenta62cf4c3e3233e86aa46c0067871269fe7066765 (diff)
downloadmu-e689294c4b1d3b256a0958070948fa146182cfc1.tar.gz
3141
Thanks Stephen Malina for helping run into this hole in support for
compound types.

When I created that assert (commit 2381, Nov 2015) I was thinking only
of type ingredients, and didn't realize that compound types could have
internal nodes with zero values.
-rw-r--r--030container.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/030container.cc b/030container.cc
index 56cae250..8784c75c 100644
--- a/030container.cc
+++ b/030container.cc
@@ -712,6 +712,12 @@ container foo [
 +parse: element: {x: "number"}
 +parse: element: {y: "number"}
 
+:(scenario container_with_compount_field_type)
+container foo [
+  {x: (table (address array character) number)}
+]
+$error: 0
+
 :(before "End transform_all")
 check_container_field_types();
 
@@ -727,12 +733,10 @@ void check_container_field_types() {
 
 void check_invalid_types(const type_tree* type, const string& block, const string& name) {
   if (!type) return;  // will throw a more precise error elsewhere
-  if (type->value == 0) {
-    assert(!type->left && !type->right);
-    return;
+  if (type->value != 0) {  // value 0 = compound types (layer parse_tree) or type ingredients (layer shape_shifting_container)
+    if (!contains_key(Type, type->value))
+      raise << block << "unknown type in " << name << '\n' << end();
   }
-  if (!contains_key(Type, type->value))
-    raise << block << "unknown type in " << name << '\n' << end();
   check_invalid_types(type->left, block, name);
   check_invalid_types(type->right, block, name);
 }