1
0
mirror of https://github.com/golang/go synced 2024-11-17 21:44:43 -07:00
go/test/fixedbugs/issue50190.go
Matthew Dempsky 1a8b4e05b1 cmd/compile: unique LinkString for renamed, embedded fields
Using type aliases, it's possible to create structs with embedded
fields that have no corresponding type literal notation. However, we
still need to generate a unique name for these types to use for linker
symbols. This CL introduces a new "struct{ Name = Type }" syntax for
use in LinkString formatting to represent these types.

Reattempt at CL 372914, which was rolled back due to race-y
LocalPkg.Lookup call that isn't safe for concurrency.

Fixes #50190.

Change-Id: I0b7fd81e1b0b3199a6afcffde96ade42495ad8d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/378434
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2022-01-13 21:37:29 +00:00

32 lines
446 B
Go

// run
// 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.
package main
type Int = int
type A = struct{ int }
type B = struct{ Int }
func main() {
var x, y interface{} = A{}, B{}
if x == y {
panic("FAIL")
}
{
type C = int32
x = struct{ C }{}
}
{
type C = uint32
y = struct{ C }{}
}
if x == y {
panic("FAIL")
}
}