mirror of
https://github.com/golang/go.git
synced 2025-10-25 13:54:14 +00:00
make every func literal expression allocate,
so that == on func means that the
functions originated in the same
execution of a func literal or definition.
before, there was an inconsistency:
func() {x++} != func() {x++}
but
func() {} == func() {}
this CL makes the second case != too,
just like
make(map[int]int) != make(map[int]int)
R=r
DELTA=202 (71 added, 62 deleted, 69 changed)
OCL=32393
CL=32398
This commit is contained in:
parent
83940d7c4a
commit
9346c6d901
4 changed files with 141 additions and 132 deletions
|
|
@ -73,6 +73,10 @@ func h() {
|
|||
f(500);
|
||||
}
|
||||
|
||||
func newfunc() (func(int) int) {
|
||||
return func(x int) int { return x }
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
go f();
|
||||
|
|
@ -85,4 +89,12 @@ func main() {
|
|||
|
||||
go h();
|
||||
check([]int{100,200,101,201,500,101,201,500});
|
||||
|
||||
x, y := newfunc(), newfunc();
|
||||
if x == y {
|
||||
panicln("newfunc returned same func");
|
||||
}
|
||||
if x(1) != 1 || y(2) != 2 {
|
||||
panicln("newfunc returned broken funcs");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue