mirror of
https://github.com/golang/go
synced 2024-10-05 16:31:21 -06:00
[dev.ssa] cmd/compile/internal: mark len(map), len/cap(chan) unimplemented
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>
This commit is contained in:
parent
57d9e7e3c4
commit
0ffd9c8cad
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user