]> Cypherpunks repositories - gostls13.git/commit
go/types: correctly compute cycle length
authorRobert Griesemer <gri@golang.org>
Fri, 29 Jun 2018 21:11:46 +0000 (14:11 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 10 Jul 2018 14:33:10 +0000 (14:33 +0000)
commit9ab5154f6ceb0211d8a29005c0f4d4851f0d4e4f
tree54b53305000bbb1297e5da3bbf4a58a1de2ede89
parent34619d5d13ac79c605e0941f62730f5c8dfea4c1
go/types: correctly compute cycle length

The existing algorithm assumed that the length of a cycle was simply
the number of elements in the cycle slice starting at the start object.
However, we use a special "indir" indirection object to indicate
pointer and other indirections that break the inline placement of
types in composite types. These indirection objects don't exist as
true named type objects, so don't count them anymore.

This removes an unnecessary cycle error in one of the existing tests
(testdata/issues.src:100).

Also:
- added more tracing support (only active if tracing is enabled)
- better documentation in parts
- r/check.typ/check.typExpr/ in a few of places where we don't
  need to record a type indirection

Found while investigating #26124.

Change-Id: I45341743225d979a72af3fbecfa05012b32fab67
Reviewed-on: https://go-review.googlesource.com/121755
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/check.go
src/go/types/decl.go
src/go/types/expr.go
src/go/types/testdata/issues.src