]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: correct alias cycle detection
authorRobert Griesemer <gri@golang.org>
Wed, 6 Jun 2018 17:21:15 +0000 (10:21 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 12 Jun 2018 18:55:39 +0000 (18:55 +0000)
commit48987baa09856ea6f656abe8a90d264070db8fad
tree15e10d53ad10b619656d485c5530b6e2c7c02fc5
parentdda7985a7b748e7149dc46c29611c2ec6e861340
cmd/compile: correct alias cycle detection

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>
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/typecheck.go
test/fixedbugs/issue18640.go
test/fixedbugs/issue23823.go [new file with mode: 0644]
test/fixedbugs/issue24939.go [new file with mode: 0644]