From 5fe4063ee58092c1733e404ce7cbd9729e431b1f Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Tue, 20 Oct 2026 13:39:40 -0400 Subject: [PATCH 1/2] Use JSON field names in BenchmarkCheck BenchmarkCheck builds its environment the way TestCheck does, but it ignored testEnv.jsonFieldNames, so the cases that set it reported undefined fields and failed. It now passes JSONFieldNames to both the registry and the checker, as TestCheck does. --- checker/checker_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/checker/checker_test.go b/checker/checker_test.go index 6e40e2b80..6cc067ce6 100644 --- a/checker/checker_test.go +++ b/checker/checker_test.go @@ -2655,7 +2655,10 @@ func BenchmarkCheck(b *testing.B) { if len(errors.GetErrors()) > 0 { b.Fatalf("Unexpected parse errors: %v", errors.ToDisplayString()) } - reg, err := types.NewRegistry(types.ProtoTypeDefs(&proto2pb.TestAllTypes{}, &proto3pb.TestAllTypes{})) + reg, err := types.NewRegistry( + types.JSONFieldNames(tc.env.jsonFieldNames), + types.ProtoTypeDefs(&proto2pb.TestAllTypes{}, &proto3pb.TestAllTypes{}), + ) if err != nil { b.Fatalf("types.NewRegistry() failed: %v", err) } @@ -2672,6 +2675,9 @@ func BenchmarkCheck(b *testing.B) { if len(tc.opts) != 0 { opts = tc.opts } + if tc.env.jsonFieldNames { + opts = append(opts, JSONFieldNames(true)) + } env, err := NewEnv(cont, reg, opts...) if err != nil { b.Fatalf("NewEnv(cont, reg) failed: %v", err) From bdae7fda7233ed7db1e262ca0c7a514a5eb1ce0e Mon Sep 17 00:00:00 2001 From: Stefan VanBuren Date: Tue, 20 Oct 2026 22:19:37 -0400 Subject: [PATCH 2/2] Check a fresh AST in each BenchmarkCheck iteration Check rewrites the parsed AST in place, for example replacing a qualified select with an identifier, so iterations after the first checked an already rewritten AST. For `.y.z` the rewrite drops the leading dot, and the case failed whenever b.N was above 1. Each iteration now checks a copy of the parsed AST. --- checker/checker_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checker/checker_test.go b/checker/checker_test.go index 6cc067ce6..bd735e1d0 100644 --- a/checker/checker_test.go +++ b/checker/checker_test.go @@ -2697,7 +2697,7 @@ func BenchmarkCheck(b *testing.B) { } b.ResetTimer() for i := 0; i < b.N; i++ { - cAst, errors := Check(pAst, src, env) + cAst, errors := Check(ast.Copy(pAst), src, env) if len(errors.GetErrors()) > 0 { errorString := errors.ToDisplayString() if tc.err != "" {