]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: Use left-hand side's type as hint for right-hand
authorAndrew Wilkins <axwalk@gmail.com>
Tue, 19 Feb 2013 17:20:56 +0000 (09:20 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 19 Feb 2013 17:20:56 +0000 (09:20 -0800)
side expression evaluation in assignment operations.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/7349046

src/pkg/exp/gotype/gotype_test.go
src/pkg/go/types/stmt.go
src/pkg/go/types/testdata/stmt0.src

index 3fbada7920a928a6a15401eef8a122232938c49a..03c114013a61b04ee3a6e498cbeec767adb952a7 100644 (file)
@@ -61,7 +61,7 @@ var tests = []string{
        "bufio",
        "bytes",
 
-       // "compress/bzip2",
+       "compress/bzip2",
        "compress/flate",
        "compress/gzip",
        // "compress/lzw",
@@ -80,7 +80,7 @@ var tests = []string{
        "crypto/elliptic",
        "crypto/hmac",
        "crypto/md5",
-       // "crypto/rand",
+       "crypto/rand",
        "crypto/rc4",
        "crypto/rsa",
        "crypto/sha1",
@@ -126,7 +126,7 @@ var tests = []string{
        "go/parser",
        "go/printer",
        "go/scanner",
-       // "go/token",
+       "go/token",
        "go/types",
 
        "hash/adler32",
@@ -138,7 +138,7 @@ var tests = []string{
        "image/color",
        "image/draw",
        "image/gif",
-       // "image/jpeg",
+       "image/jpeg",
        "image/png",
 
        "index/suffixarray",
@@ -149,7 +149,7 @@ var tests = []string{
        "log",
        "log/syslog",
 
-       // "math",
+       "math",
        //"math/big",
        "math/cmplx",
        "math/rand",
@@ -168,7 +168,7 @@ var tests = []string{
        "net/rpc",
        "net/rpc/jsonrpc",
        "net/smtp",
-       // "net/textproto",
+       "net/textproto",
        "net/url",
 
        "path",
index 05a65ca2c02e1344d6b6d02e9728a5334a6f8385..2da798e4ca04e658cfb1c5804ef64d8a7557e267 100644 (file)
@@ -403,11 +403,13 @@ func (check *checker) stmt(s ast.Stmt) {
                                return
                        }
                        var x, y operand
+                       // The lhs operand's type doesn't need a hint (from the rhs operand),
+                       // because it must be a fully typed variable in this case.
                        check.expr(&x, s.Lhs[0], nil, -1)
                        if x.mode == invalid {
                                return
                        }
-                       check.expr(&y, s.Rhs[0], nil, -1)
+                       check.expr(&y, s.Rhs[0], x.typ, -1)
                        if y.mode == invalid {
                                return
                        }
index ca36834fde6d508368b5c75052a3907c9487a01d..37610d3ddd15792a159a6d043e86a9da06fc75ba 100644 (file)
@@ -29,6 +29,9 @@ func _() {
 
        s += "bar"
        s += 1 /* ERROR "cannot convert.*string" */
+
+       var u64 uint64
+       u64 += 1<<u64
 }
 
 func _incdecs() {
@@ -271,4 +274,4 @@ func _rangeloops() {
                var xx rune
                xx = x
        }
-}
\ No newline at end of file
+}