From 0e13d068ad050d4ca81ec8d8fb0320d0a0b12331 Mon Sep 17 00:00:00 2001 From: Michael Urman Date: Wed, 29 May 2024 10:07:03 -0500 Subject: [PATCH] Fix array test The prior construct probably shouldn't issue an error. These, however, both should (and do). --- testdata/src/example.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/testdata/src/example.go b/testdata/src/example.go index a7e83a8..c9c6ea2 100644 --- a/testdata/src/example.go +++ b/testdata/src/example.go @@ -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") } }