mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] cmd/compile: fix small -G=3 issues for tests disabled in run.go
- set correct position for closure capture variable in (*irgen).use() (issue20250.go) Also, evaluate rhs, lhs in that order in assignment statements to match noder1 (affects ordering of closure variables). - make sure to set Assign flag properly in (*irgen).forStmt() for range variables which are map accesses (issue9691.go) - make sure CheckSize() is call on the base type for top-level types converted by (*irgen).typ() that are pointer types (issue20174.go and issue37837.go) - deal with parentheses properly in validation function (*irgen).validate() (issue17270.go) - avoid HasNil call on type TTYPEPARAM - types2 typechecker will have already checked validity of the typeparam having nil value (new test issue39755.go) Change-Id: Ie68004d964698aea047e19e7dcd79b297e9d47ca Reviewed-on: https://go-review.googlesource.com/c/go/+/334733 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
3d8453e00e
commit
ed9e109dc9
7 changed files with 58 additions and 11 deletions
|
|
@ -57,7 +57,10 @@ func (g *irgen) stmt(stmt syntax.Stmt) ir.Node {
|
|||
if stmt.Rhs == nil {
|
||||
n = IncDec(g.pos(stmt), op, g.expr(stmt.Lhs))
|
||||
} else {
|
||||
n = ir.NewAssignOpStmt(g.pos(stmt), op, g.expr(stmt.Lhs), g.expr(stmt.Rhs))
|
||||
// Eval rhs before lhs, for compatibility with noder1
|
||||
rhs := g.expr(stmt.Rhs)
|
||||
lhs := g.expr(stmt.Lhs)
|
||||
n = ir.NewAssignOpStmt(g.pos(stmt), op, lhs, rhs)
|
||||
}
|
||||
if n.X.Typecheck() == 3 {
|
||||
n.SetTypecheck(3)
|
||||
|
|
@ -68,8 +71,9 @@ func (g *irgen) stmt(stmt syntax.Stmt) ir.Node {
|
|||
return n
|
||||
}
|
||||
|
||||
names, lhs := g.assignList(stmt.Lhs, stmt.Op == syntax.Def)
|
||||
// Eval rhs before lhs, for compatibility with noder1
|
||||
rhs := g.exprList(stmt.Rhs)
|
||||
names, lhs := g.assignList(stmt.Lhs, stmt.Op == syntax.Def)
|
||||
|
||||
// We must delay transforming the assign statement if any of the
|
||||
// lhs or rhs nodes are also delayed, since transformAssign needs
|
||||
|
|
@ -262,6 +266,12 @@ func (g *irgen) forStmt(stmt *syntax.ForStmt) ir.Node {
|
|||
key, value := unpackTwo(lhs)
|
||||
n := ir.NewRangeStmt(g.pos(r), key, value, g.expr(r.X), g.blockStmt(stmt.Body))
|
||||
n.Def = initDefn(n, names)
|
||||
if key != nil {
|
||||
transformCheckAssign(n, key)
|
||||
}
|
||||
if value != nil {
|
||||
transformCheckAssign(n, value)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue