mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
cmd/compile: fix export type conversion loss in inlined func body
Fixes #12677. Change-Id: I72012f55615fcf5f4a16c054706c9bcd82e49ccd Reviewed-on: https://go-review.googlesource.com/17817 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
a40281112c
commit
91c8e5f80b
@ -1120,7 +1120,7 @@ func exprfmt(n *Node, prec int) string {
|
|||||||
if n.Val().Ctype() == CTNIL && n.Orig != nil && n.Orig != n {
|
if n.Val().Ctype() == CTNIL && n.Orig != nil && n.Orig != n {
|
||||||
return exprfmt(n.Orig, prec)
|
return exprfmt(n.Orig, prec)
|
||||||
}
|
}
|
||||||
if n.Type != nil && n.Type != Types[n.Type.Etype] && n.Type != idealbool && n.Type != idealstring {
|
if n.Type != nil && n.Type.Etype != TIDEAL && n.Type.Etype != TNIL && n.Type != idealbool && n.Type != idealstring {
|
||||||
// Need parens when type begins with what might
|
// Need parens when type begins with what might
|
||||||
// be misinterpreted as a unary operator: * or <-.
|
// be misinterpreted as a unary operator: * or <-.
|
||||||
if Isptr[n.Type.Etype] || (n.Type.Etype == TCHAN && n.Type.Chan == Crecv) {
|
if Isptr[n.Type.Etype] || (n.Type.Etype == TCHAN && n.Type.Chan == Crecv) {
|
||||||
|
8
test/fixedbugs/issue12677.dir/p.go
Normal file
8
test/fixedbugs/issue12677.dir/p.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package p
|
||||||
|
func Baz(f int) float64 {
|
||||||
|
return 1 / float64(int(1)<<(uint(f)))
|
||||||
|
}
|
7
test/fixedbugs/issue12677.dir/q.go
Normal file
7
test/fixedbugs/issue12677.dir/q.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package q
|
||||||
|
import "./p"
|
||||||
|
func f() { println(p.Baz(2)) }
|
9
test/fixedbugs/issue12677.go
Normal file
9
test/fixedbugs/issue12677.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// compiledir
|
||||||
|
|
||||||
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Issue 12677: Type loss during export/import of inlined function body.
|
||||||
|
|
||||||
|
package ignored
|
Loading…
x
Reference in New Issue
Block a user