diff --git a/compiler2/Type.cc b/compiler2/Type.cc
index 8943ce32fa8b369479b5612367bf9f709c3b71da..b5bd3e1c44f08f71cc5f0509a2aafb5f73b7cabc 100644
--- a/compiler2/Type.cc
+++ b/compiler2/Type.cc
@@ -1774,7 +1774,7 @@ namespace Common {
                 pt->get_typename().c_str());
               return 0;
             }
-            len = pt->get_sub_type()->get_length_restriction();
+            len = sub->get_length_restriction();
             if (len == -1) {
               ref->error("The type `%s' must have single size length restriction when used as a short-hand notation for nested indexes.",
                 pt->get_typename().c_str());