From 3d7cb23e3d5e7880d582f1b0300064bd1138f3ee Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Tue, 16 Nov 2021 18:44:08 -0500 Subject: [PATCH] cmd/compile: emit definition of 'any' when compiling runtime Include the predefined type 'any' in the list of other important predefined types that are emitted when compiling the runtime package (uintptr, string, etc). Fixes #49619. Change-Id: I4a851ba2f302fbc3a425e65daa325c6bf83659da Reviewed-on: https://go-review.googlesource.com/c/go/+/364377 Trust: Than McIntosh Trust: Dan Scales Run-TryBot: Than McIntosh TryBot-Result: Go Bot Reviewed-by: Dan Scales --- .../compile/internal/reflectdata/reflect.go | 1 + test/fixedbugs/issue49619.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 test/fixedbugs/issue49619.go diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 4e20dbf29e..e22fabb410 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -1384,6 +1384,7 @@ func WriteBasicTypes() { } writeType(types.NewPtr(types.Types[types.TSTRING])) writeType(types.NewPtr(types.Types[types.TUNSAFEPTR])) + 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 new file mode 100644 index 0000000000..c9f3cbc4ad --- /dev/null +++ b/test/fixedbugs/issue49619.go @@ -0,0 +1,19 @@ +// build + +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// This testcase caused a linker crash in DWARF generation. + +package main + +//go:noinline +func f() any { + var a []any + return a[0] +} + +func main() { + f() +} -- 2.50.0