]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: emit definition of 'any' only if generic enabled
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 17 Nov 2021 03:17:31 +0000 (10:17 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 17 Nov 2021 04:55:12 +0000 (04:55 +0000)
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 <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
src/cmd/compile/internal/reflectdata/reflect.go
test/fixedbugs/issue49619.go

index e22fabb4108a81d9ad32b84bdae0a7dfcf0d6868..f35baabbf9c3d52a52b71579eb99106686573b83 100644 (file)
@@ -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.
index c9f3cbc4ad38de09ca08df53ab2a78a2a725d169..f34dfac1920c5f7c936dd9c141ec134502851932 100644 (file)
@@ -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