Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/types: cyclical type declaration accepted w/o error #8699

Closed
griesemer opened this issue Sep 10, 2014 · 4 comments
Closed

go/types: cyclical type declaration accepted w/o error #8699

griesemer opened this issue Sep 10, 2014 · 4 comments

Comments

@griesemer
Copy link
Contributor

@griesemer griesemer commented Sep 10, 2014

The program:

http://play.golang.org/p/HVo1iZeaiW

is accepted by gotype w/o an error.

Both gc and gccgo complain.

$ gccgo x.go
x.go:3:9: error: array bound is not constant
 type T [len(a)]int
         ^
@griesemer
Copy link
Contributor Author

@griesemer griesemer commented Sep 17, 2014

Comment 2:

Simpler test case:
package p
type T [len(a)]int
var a T

Loading

@griesemer
Copy link
Contributor Author

@griesemer griesemer commented Sep 17, 2014

Comment 3:

In some cases the type-checker ignores the fact that the underlying type is incomplete:
When declaring T, as soon as we know that we have an array, T is declared as such with
length 0 (and no element type), but that is sufficient for len(a) to get a useful length
(namely 0).
Fixing this is subtle; it's also an academic case. Delay to 1.5.

Labels changed: added release-go1.5, removed release-go1.4.

Loading

@griesemer griesemer self-assigned this Sep 17, 2014
@bradfitz bradfitz added this to the Go1.5 milestone Dec 16, 2014
@bradfitz bradfitz added this to the Go1.5 milestone Dec 16, 2014
@rsc rsc removed accepted labels Apr 14, 2015
@rsc rsc changed the title go/types: cyclical type declaration accepted w/o error x/tools/go/types: cyclical type declaration accepted w/o error Apr 14, 2015
@rsc rsc added this to the Unreleased milestone Apr 14, 2015
@rsc rsc removed this from the Go1.5 milestone Apr 14, 2015
@rsc rsc removed the repo-tools label Apr 14, 2015
@griesemer griesemer changed the title x/tools/go/types: cyclical type declaration accepted w/o error go/types: cyclical type declaration accepted w/o error Jul 31, 2015
@griesemer griesemer added this to the Unplanned milestone Jul 31, 2015
@griesemer griesemer removed this from the Unreleased milestone Jul 31, 2015
@griesemer griesemer added this to the Go1.10 milestone Jun 29, 2017
@griesemer griesemer removed this from the Unplanned milestone Jun 29, 2017
@rsc rsc removed this from the Go1.10 milestone Nov 22, 2017
@rsc rsc added this to the Go1.11 milestone Nov 22, 2017
@gopherbot
Copy link

@gopherbot gopherbot commented May 31, 2018

Change https://golang.org/cl/115457 mentions this issue: go/types: report object path in trace mode

Loading

gopherbot pushed a commit that referenced this issue May 31, 2018
For debugging only; disabled (dead code) by default
unless internal constant trace flag is set to true.

For #8699.

Change-Id: Ib7b272c6ac8efacccbbbe24650ef500c5a9ddcf5
Reviewed-on: https://go-review.googlesource.com/115457
Reviewed-by: Alan Donovan <adonovan@google.com>
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 6, 2018

Change https://golang.org/cl/116815 mentions this issue: go/types: extend cycle detection past simple type cycles

Loading

@gopherbot gopherbot closed this in d8a1465 Jun 7, 2018
@golang golang locked and limited conversation to collaborators Jun 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants