Skip to content

Commit

Permalink
Fix array test
Browse files Browse the repository at this point in the history
The prior construct probably shouldn't issue an error.
These, however, both should (and do).
  • Loading branch information
MichaelUrman committed May 29, 2024
1 parent 3e9e29f commit 0e13d06
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions testdata/src/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ func inStructs(ctx context.Context) {
c.Ctx = context.WithValue(c.Ctx, "other", "val")
}

r := []struct{ Ctx context.Context }{{ctx}}
for i := 0; i < 10; i++ {
c := []*struct{ Ctx context.Context }{{ctx}}
c[0].Ctx = context.WithValue(c[0].Ctx, "key", i) // want "nested context in loop"
c[0].Ctx = context.WithValue(c[0].Ctx, "other", "val")
r[0].Ctx = context.WithValue(r[0].Ctx, "key", i) // want "nested context in loop"
r[0].Ctx = context.WithValue(r[0].Ctx, "other", "val")
}

rp := []*struct{ Ctx context.Context }{{ctx}}
for i := 0; i < 10; i++ {
rp[0].Ctx = context.WithValue(rp[0].Ctx, "key", i) // want "nested context in loop"
rp[0].Ctx = context.WithValue(rp[0].Ctx, "other", "val")
}
}

0 comments on commit 0e13d06

Please sign in to comment.