]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile/internal: mark len(map), len/cap(chan) unimplemented
authorTodd Neal <todd@tneal.org>
Sat, 22 Aug 2015 02:38:41 +0000 (21:38 -0500)
committerTodd Neal <todd@tneal.org>
Sat, 22 Aug 2015 13:15:27 +0000 (13:15 +0000)
Mark these as unimplemented so we don't generate bad code.

Change-Id: I101190c40a753faaa82193ac37e2978b20a96e4e
Reviewed-on: https://go-review.googlesource.com/13748
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/type.go

index 6d3359ad0e5beb02cdae563194895d45d754b146..a7349a8f1f049139779fbe11ff5f81906908d77b 100644 (file)
@@ -1349,6 +1349,16 @@ func (s *state) expr(n *Node) *ssa.Value {
                        return s.newValue1(op, Types[TINT], s.expr(n.Left))
                case n.Left.Type.IsString(): // string; not reachable for OCAP
                        return s.newValue1(ssa.OpStringLen, Types[TINT], s.expr(n.Left))
+               case n.Left.Type.IsMap():
+                       s.Unimplementedf("unhandled len(map)")
+                       return nil
+               case n.Left.Type.IsChan():
+                       if n.Op == OCAP {
+                               s.Unimplementedf("unhandled cap(chan)")
+                       } else {
+                               s.Unimplementedf("unhandled len(chan)")
+                       }
+                       return nil
                default: // array
                        return s.constInt(Types[TINT], n.Left.Type.Bound)
                }
index bcad025ba646d40a3097884105e1a222e5bae02e..697152bebd582de2958fbcb2e1ccf40da33a8088 100644 (file)
@@ -64,6 +64,14 @@ func (t *Type) IsString() bool {
        return t.Etype == TSTRING
 }
 
+func (t *Type) IsMap() bool {
+       return t.Etype == TMAP
+}
+
+func (t *Type) IsChan() bool {
+       return t.Etype == TCHAN
+}
+
 func (t *Type) IsSlice() bool {
        return t.Etype == TARRAY && t.Bound < 0
 }