Skip to content

Commit 3d7cb23

Browse files
committed
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 <[email protected]> Trust: Dan Scales <[email protected]> Run-TryBot: Than McIntosh <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Dan Scales <[email protected]>
1 parent a2b8231 commit 3d7cb23

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,7 @@ func WriteBasicTypes() {
13841384
}
13851385
writeType(types.NewPtr(types.Types[types.TSTRING]))
13861386
writeType(types.NewPtr(types.Types[types.TUNSAFEPTR]))
1387+
writeType(types.AnyType)
13871388

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

test/fixedbugs/issue49619.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// build
2+
3+
// Copyright 2021 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// This testcase caused a linker crash in DWARF generation.
8+
9+
package main
10+
11+
//go:noinline
12+
func f() any {
13+
var a []any
14+
return a[0]
15+
}
16+
17+
func main() {
18+
f()
19+
}

0 commit comments

Comments
 (0)