]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile: port fix for issue46725 to transform.go
authorDan Scales <danscales@google.com>
Mon, 28 Jun 2021 18:50:26 +0000 (11:50 -0700)
committerDan Scales <danscales@google.com>
Mon, 28 Jun 2021 20:52:43 +0000 (20:52 +0000)
Allow fix for issue46725 to work for -G=3 mode.

Change-Id: Id522fbc2278cf878cb3f95b3205a2122c164ae29
Reviewed-on: https://go-review.googlesource.com/c/go/+/331470
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/noder/transform.go
src/cmd/compile/internal/typecheck/stmt.go
src/cmd/compile/internal/typecheck/typecheck.go
test/run.go

index c3fa8042f2c49e5263419c5e93828ebae1edff2e..7a685c4b47038696f098f4d622fdb2c3d9d200cc 100644 (file)
@@ -329,8 +329,20 @@ assignOK:
                r.Use = ir.CallUseList
                rtyp := r.Type()
 
+               mismatched := false
+               failed := false
                for i := range lhs {
-                       checkLHS(i, rtyp.Field(i).Type)
+                       result := rtyp.Field(i).Type
+                       checkLHS(i, result)
+
+                       if lhs[i].Type() == nil || result == nil {
+                               failed = true
+                       } else if lhs[i] != ir.BlankNode && !types.Identical(lhs[i].Type(), result) {
+                               mismatched = true
+                       }
+               }
+               if mismatched && !failed {
+                       typecheck.RewriteMultiValueCall(stmt, r)
                }
                return
        }
index 54cf508acc1a645e7651d72cb5352e69f1dc8738..f1275f29c07aa6c01dec8862e7739ec79a07fbd5 100644 (file)
@@ -217,7 +217,7 @@ assignOK:
                        }
                }
                if mismatched && !failed {
-                       rewriteMultiValueCall(stmt, r)
+                       RewriteMultiValueCall(stmt, r)
                }
                return
        }
index f7de43c79f8f49d11cde6a67b07e5aa6567cf8e5..232c0e66ef3452b9687ffdc290827a59082b151f 100644 (file)
@@ -962,12 +962,12 @@ func typecheckargs(n ir.InitNode) {
        }
 
        // Rewrite f(g()) into t1, t2, ... = g(); f(t1, t2, ...).
-       rewriteMultiValueCall(n, list[0])
+       RewriteMultiValueCall(n, list[0])
 }
 
-// rewriteMultiValueCall rewrites multi-valued f() to use temporaries,
+// RewriteMultiValueCall rewrites multi-valued f() to use temporaries,
 // so the backend wouldn't need to worry about tuple-valued expressions.
-func rewriteMultiValueCall(n ir.InitNode, call ir.Node) {
+func RewriteMultiValueCall(n ir.InitNode, call ir.Node) {
        // If we're outside of function context, then this call will
        // be executed during the generated init function. However,
        // init.go hasn't yet created it. Instead, associate the
index ad92d8bb79c35574b348e5634b0f13c7356d8645..d04f7d20ed8f174c5d68adc58f63bd070db10e15 100644 (file)
@@ -2131,7 +2131,6 @@ var excludedFiles = map[string]bool{
        "fixedbugs/issue4232.go":   true, // types2 reports (correct) extra errors
        "fixedbugs/issue4452.go":   true, // types2 reports (correct) extra errors
        "fixedbugs/issue4510.go":   true, // types2 reports different (but ok) line numbers
-       "fixedbugs/issue46725.go":  true, // fix applied to typecheck needs to be ported to irgen/transform
        "fixedbugs/issue5609.go":   true, // types2 needs a better error message
        "fixedbugs/issue7525b.go":  true, // types2 reports init cycle error on different line - ok otherwise
        "fixedbugs/issue7525c.go":  true, // types2 reports init cycle error on different line - ok otherwise