From 1d004fa2015d128acf6302fc74b95f6a36c35680 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 17 Nov 2021 10:17:31 +0700 Subject: [PATCH] cmd/compile: emit definition of 'any' only if generic enabled CL 364377 emitted definition of 'any' when compiling runtime. But 'any' is only available when generic enabled. Thus emitting its definition unconditionally causes the compiler crashes. Updates #49619 Change-Id: I0888ca1cbc7a7df300310a99a344f170636333f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/364614 Trust: Cuong Manh Le Trust: Dan Scales Run-TryBot: Cuong Manh Le TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/cmd/compile/internal/reflectdata/reflect.go | 4 +++- test/fixedbugs/issue49619.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index e22fabb4108..f35baabbf9c 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -1384,7 +1384,9 @@ func WriteBasicTypes() { } writeType(types.NewPtr(types.Types[types.TSTRING])) writeType(types.NewPtr(types.Types[types.TUNSAFEPTR])) - writeType(types.AnyType) + if base.Flag.G > 0 { + writeType(types.AnyType) + } // emit type structs for error and func(error) string. // The latter is the type of an auto-generated wrapper. diff --git a/test/fixedbugs/issue49619.go b/test/fixedbugs/issue49619.go index c9f3cbc4ad3..f34dfac1920 100644 --- a/test/fixedbugs/issue49619.go +++ b/test/fixedbugs/issue49619.go @@ -1,4 +1,4 @@ -// build +// build -gcflags=-G=3 // Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style