Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
sayboras committed May 23, 2020
1 parent 0747484 commit 2b78469
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/testdata/exportloopref.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//args: -Eexportloopref
package testdata

func dummyFunction() {
Expand All @@ -8,19 +9,19 @@ func dummyFunction() {

println("loop expecting 10, 11, 12, 13")
for i, p := range []int{10, 11, 12, 13} {
printp(&p) // not a diagnostic
slice = append(slice, &p) // want "exporting a pointer for the loop variable p"
array[i] = &p // want "exporting a pointer for the loop variable p"
printp(&p)
slice = append(slice, &p) // ERROR : exporting a pointer for the loop variable p
array[i] = &p // ERROR : exporting a pointer for the loop variable p
if i%2 == 0 {
ref = &p // want "exporting a pointer for the loop variable p"
str.x = &p // want "exporting a pointer for the loop variable p"
ref = &p // ERROR : exporting a pointer for the loop variable p
str.x = &p // ERROR : exporting a pointer for the loop variable p
}
var vStr struct{ x *int }
var vArray [4]*int
var v *int
if i%2 == 0 {
v = &p // not a diagnostic (x is inner variable)
vArray[1] = &p // not a diagnostic (x is inner variable)
v = &p
vArray[1] = &p
vStr.x = &p
}
_ = v
Expand Down

0 comments on commit 2b78469

Please sign in to comment.