From: Robert Griesemer Date: Wed, 27 Feb 2013 22:24:41 +0000 (-0800) Subject: go/types: don't crash when assigning to undefined variables X-Git-Tag: go1.1rc2~803 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=029457aab54c8c8ae25aaf51725d002aaba8749c;p=gostls13.git go/types: don't crash when assigning to undefined variables R=adonovan CC=golang-dev https://golang.org/cl/7369059 --- diff --git a/src/pkg/go/types/stmt.go b/src/pkg/go/types/stmt.go index 730b0608ee..65b12a01ef 100644 --- a/src/pkg/go/types/stmt.go +++ b/src/pkg/go/types/stmt.go @@ -62,6 +62,10 @@ func (check *checker) assign1to1(lhs, rhs ast.Expr, x *operand, decl bool, iota } } + if x.mode == invalid || z.mode == invalid { + return + } + check.assignOperand(&z, x) if x.mode != invalid && z.mode == constant { check.errorf(x.pos(), "cannot assign %s to %s", x, &z) diff --git a/src/pkg/go/types/testdata/stmt0.src b/src/pkg/go/types/testdata/stmt0.src index 37610d3ddd..d4e08f6c0d 100644 --- a/src/pkg/go/types/testdata/stmt0.src +++ b/src/pkg/go/types/testdata/stmt0.src @@ -32,6 +32,8 @@ func _() { var u64 uint64 u64 += 1<