Skip to content

Commit 1d004fa

Browse files
committed
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 <[email protected]> Trust: Dan Scales <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Dan Scales <[email protected]>
1 parent 03dd049 commit 1d004fa

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/cmd/compile/internal/reflectdata/reflect.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,9 @@ func WriteBasicTypes() {
13841384
}
13851385
writeType(types.NewPtr(types.Types[types.TSTRING]))
13861386
writeType(types.NewPtr(types.Types[types.TUNSAFEPTR]))
1387-
writeType(types.AnyType)
1387+
if base.Flag.G > 0 {
1388+
writeType(types.AnyType)
1389+
}
13881390

13891391
// emit type structs for error and func(error) string.
13901392
// The latter is the type of an auto-generated wrapper.

test/fixedbugs/issue49619.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// build
1+
// build -gcflags=-G=3
22

33
// Copyright 2021 The Go Authors. All rights reserved.
44
// Use of this source code is governed by a BSD-style

0 commit comments

Comments
 (0)