compiler: better error messages for slicing invalid types

Change-Id: Iab59de0e4c755776c76a6eedafd1a592be446761
Reviewed-on: https://go-review.googlesource.com/43457
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/go/expressions.cc b/go/expressions.cc
index c5e9a0b..97a39f5 100644
--- a/go/expressions.cc
+++ b/go/expressions.cc
@@ -10610,10 +10610,24 @@
 	}
       return Expression::make_map_index(left, start, location);
     }
+  else if (cap != NULL)
+    {
+      go_error_at(location,
+		  "invalid 3-index slice of object that is not a slice");
+      return Expression::make_error(location);
+    }
+  else if (end != NULL)
+    {
+      go_error_at(location,
+		  ("attempt to slice object that is not "
+		   "array, slice, or string"));
+      return Expression::make_error(location);
+    }
   else
     {
       go_error_at(location,
-                  "attempt to index object which is not array, string, or map");
+                  ("attempt to index object that is not "
+		   "array, slice, string, or map"));
       return Expression::make_error(location);
     }
 }