mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/gc: distinguish unnamed vs blank-named return variables better
Before, an unnamed return value turned into an ONAME node n with n->sym named ~anon%d, and n->orig == n. A blank-named return value turned into an ONAME node n with n->sym named ~anon%d but n->orig == the original blank n. Code generation and printing uses n->orig, so that this node formatted as _. But some code does not use n->orig. In particular the liveness code does not know about the n->orig convention and so mishandles blank identifiers. It is possible to fix but seemed better to avoid the confusion entirely. Now the first kind of node is named ~r%d and the second ~b%d; both have n->orig == n, so that it doesn't matter whether code uses n or n->orig. After this change the ->orig field is only used for other kinds of expressions, not for ONAME nodes. This requires distinguishing ~b from ~r names in a few places that care. It fixes a liveness analysis bug without actually changing the liveness code. TBR=ken2 CC=golang-codereviews https://golang.org/cl/63630043
This commit is contained in:
parent
e5d742fcad
commit
a069cf048d
5 changed files with 38 additions and 17 deletions
|
|
@ -79,3 +79,10 @@ func f5(b1 bool) {
|
|||
}
|
||||
print(**z) // ERROR "live at call to printint: x y$"
|
||||
}
|
||||
|
||||
// confusion about the _ result used to cause spurious "live at entry to f6: _".
|
||||
|
||||
func f6() (_, y string) {
|
||||
y = "hello"
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue