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

Constant declarations not checked for assignment compatibility #471

Closed
bjkail opened this issue Dec 29, 2009 · 6 comments
Closed

Constant declarations not checked for assignment compatibility #471

bjkail opened this issue Dec 29, 2009 · 6 comments

Comments

@bjkail
Copy link

bjkail commented Dec 29, 2009

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?
1. Compile the following program:
package main
const a [2]int = -1
func main() { println(a) }

What is the expected output? What do you see instead?
The program compiles and prints "-1" when executed rather than failing to
compile with an error such as:
badconst.go:2: cannot use -1 (type int) as type [2]int in constant declaration

What is your $GOOS?  $GOARCH?
GOOS=linux GOARCH=386

Which revision are you using?  (hg identify)
7929874a70ae tip

Please provide any additional information below.
It appears that the assignment compatibility check for constant
declarations is different than the check for assignments.
@peterGo
Copy link
Contributor

peterGo commented Dec 29, 2009

Comment 1:

Isn't the fundamental problem that constant arrays are illegal?

@bjkail
Copy link
Author

bjkail commented Dec 29, 2009

Comment 2:

Yes, that would probably be be a clearer error :-).  I opened this issue before I
found that constant arrays are not allowed.

@griesemer
Copy link
Contributor

Comment 3:

Owner changed to r...@golang.org.

Status changed to Accepted.

@griesemer
Copy link
Contributor

Comment 4:

Checked in test case test/bugs/bug238.go.

@rsc
Copy link
Contributor

rsc commented Jan 8, 2010

Comment 5:

Labels changed: added compilerbug.

@rsc
Copy link
Contributor

rsc commented Jan 8, 2010

Comment 6:

This issue was closed by revision 307a899.

Status changed to Fixed.

Merged into issue #-.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants