]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: don't crash when assigning to undefined variables
authorRobert Griesemer <gri@golang.org>
Wed, 27 Feb 2013 22:24:41 +0000 (14:24 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 27 Feb 2013 22:24:41 +0000 (14:24 -0800)
R=adonovan
CC=golang-dev
https://golang.org/cl/7369059

src/pkg/go/types/stmt.go
src/pkg/go/types/testdata/stmt0.src

index 730b0608eef7c44d864e9c69e7ad04a8ebf05f07..65b12a01ef1dc6b0b169a35733900222532832e0 100644 (file)
@@ -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)
index 37610d3ddd15792a159a6d043e86a9da06fc75ba..d4e08f6c0d51eb0cc304244e8d751de282abaa8b 100644 (file)
@@ -32,6 +32,8 @@ func _() {
 
        var u64 uint64
        u64 += 1<<u64
+
+       undeclared /* ERROR "undeclared" */ = 991
 }
 
 func _incdecs() {