From: Cuong Manh Le Date: Wed, 17 Nov 2021 03:17:31 +0000 (+0700) Subject: cmd/compile: emit definition of 'any' only if generic enabled X-Git-Tag: go1.18beta1~273 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=1d004fa2015d128acf6302fc74b95f6a36c35680;p=gostls13.git 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 --- diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index e22fabb410..f35baabbf9 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 c9f3cbc4ad..f34dfac192 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