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
diff --git a/test/closure.go b/test/closure.go
index 97361a1..8bb516d 100644
--- a/test/closure.go
+++ b/test/closure.go
@@ -73,6 +73,10 @@
f(500);
}
+func newfunc() (func(int) int) {
+ return func(x int) int { return x }
+}
+
func main() {
go f();
@@ -85,4 +89,12 @@
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");
+ }
}