go.tools/go/types: clean up internal iota in all cases

R=dsymonds
CC=golang-dev
https://golang.org/cl/33570043
This commit is contained in:
Robert Griesemer 2013-11-26 17:48:47 -08:00
parent 3d343e42d1
commit 62a3fc7538
2 changed files with 6 additions and 0 deletions

View File

@ -661,6 +661,7 @@ func (check *checker) constDecl(obj *Const, typ, init ast.Expr) {
if !isConstType(t) {
check.errorf(typ.Pos(), "invalid constant type %s", t)
obj.typ = Typ[Invalid]
check.iota = nil
return
}
obj.typ = t

View File

@ -13,6 +13,11 @@ const c0 = x /* ERROR "not constant" */
// typed constants must have constant types
const _ interface /* ERROR invalid constant type */ {} = 0
func _ () {
const _ interface /* ERROR invalid constant type */ {} = 0
for i := 0; i < 10; i++ {} // don't crash with non-nil iota here
}
// untyped constants
const (
// boolean values