mirror of
https://github.com/golang/go
synced 2024-11-08 18:26:14 -07:00
48987baa09
The original fix (https://go-review.googlesource.com/c/go/+/35831) for this issue was incorrect as it reported cycles in cases where it shouldn't. Instead, use a different approach: A type cycle containing aliases is only a cycle if there are no type definitions. As soon as there is a type definition, alias expansion terminates and there is no cycle. Approach: Split sprint_depchain into two non-recursive and more easily understandable functions (cycleFor and cycleTrace), and use those instead for cycle reporting. Analyze the cycle returned by cycleFor before issueing an alias cycle error. Also: Removed original fix (main.go) which introduced a separate crash (#23823). Fixes #18640. Fixes #23823. Fixes #24939. Change-Id: Ic3707a9dec40a71dc928a3e49b4868c5fac3d3b7 Reviewed-on: https://go-review.googlesource.com/118078 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
48 lines
554 B
Go
48 lines
554 B
Go
// compile
|
|
|
|
// Copyright 2017 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 p
|
|
|
|
type (
|
|
a = b
|
|
b struct {
|
|
*a
|
|
}
|
|
)
|
|
|
|
type (
|
|
c struct {
|
|
*d
|
|
}
|
|
d = c
|
|
)
|
|
|
|
// The compiler reports an incorrect (non-alias related)
|
|
// type cycle here (via dowith()). Disabled for now.
|
|
// See issue #25838.
|
|
/*
|
|
type (
|
|
e = f
|
|
f = g
|
|
g = []h
|
|
h i
|
|
i = j
|
|
j = e
|
|
)
|
|
*/
|
|
|
|
type (
|
|
a1 struct{ *b1 }
|
|
b1 = c1
|
|
c1 struct{ *b1 }
|
|
)
|
|
|
|
type (
|
|
a2 struct{ b2 }
|
|
b2 = c2
|
|
c2 struct{ *b2 }
|
|
)
|