From 62a3fc7538336a196c7049ac9e942bac1563abdb Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Tue, 26 Nov 2013 17:48:47 -0800 Subject: [PATCH] go.tools/go/types: clean up internal iota in all cases R=dsymonds CC=golang-dev https://golang.org/cl/33570043 --- go/types/resolver.go | 1 + go/types/testdata/const0.src | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/go/types/resolver.go b/go/types/resolver.go index 15f58ab5..6594334a 100644 --- a/go/types/resolver.go +++ b/go/types/resolver.go @@ -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 diff --git a/go/types/testdata/const0.src b/go/types/testdata/const0.src index b39151dd..7dd58c02 100644 --- a/go/types/testdata/const0.src +++ b/go/types/testdata/const0.src @@ -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