Skip to content

spec: oversight: §Variable declarations points to §Assignments but the relevant text does not match #8088

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

Closed
andlabs opened this issue May 24, 2014 · 5 comments
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge
Milestone

Comments

@andlabs
Copy link
Contributor

andlabs commented May 24, 2014

The Variable declarations section says

"If the type is absent and the corresponding expression evaluates to an untyped
constant, the type of the declared variable is as described in §Assignments."

The Assignemnts section says

"If an untyped constant is assigned to a variable of interface type or the blank
identifier, the constant is first converted to type bool, rune, int, float64, complex128
or string respectively, depending on whether the value is a boolean, rune, integer,
floating-point, complex, or string constant."

The problem is the phrase "variable of interface type or the blank
identifier"; it conflicts with the clause in Variable declarations. As nothing else
in the Assignments section talks about untyped constants, the Variable declarations
section now points nowhere.

This led to some confusion in #go-nuts, where jyc, dominikh, mortdeus, and myself were
going around in circles trying to find the type inference rules for variable
declarations without a type (which includes short variable declarations).

Thanks.
@ianlancetaylor
Copy link
Contributor

Comment 1:

Labels changed: added repo-main, release-go1.4.

Owner changed to @griesemer.

@griesemer
Copy link
Contributor

Comment 2:

The type of such a variable would be the same as the type of the (converted) constant if
it were assigned to a variable of interface type. But I agree that it appears that
there's a small hole in the spec.

Labels changed: added documentation.

Status changed to Accepted.

@ianlancetaylor
Copy link
Contributor

Comment 3:

Issue #8307 has been merged into this issue.

@gopherbot
Copy link
Contributor

Comment 4:

CL https://golang.org/cl/142320043 mentions this issue.

@griesemer
Copy link
Contributor

Comment 5:

This issue was closed by revision 47094dc.

Status changed to Fixed.

@andlabs andlabs added fixed Documentation Issues describing a change to documentation. labels Sep 30, 2014
@rsc rsc added this to the Go1.4 milestone Apr 14, 2015
@rsc rsc removed the release-go1.4 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 25, 2018
Not a language change.

Several inaccuracies were fixed:

1) A variable declaration may declare more than just one
variable.

2) Variable initialization follows the rules of assignments,
including n:1 assignments. The existing wording implied a 1:1
or n:n rule and generally was somewhat unspecific.

3) The rules for variable declarations with no types and
untyped initialization expressions had minor holes (issue 8088).

4) Clarified the special cases of assignments of untyped values
(we don't just have untyped constants, but also untyped bools,
e.g. from comparisons). The new wording is more direct.

To that end, introduced the notion of an untyped constant's
"default type" so that the same concept doesn't have to be
repeatedly introduced.

Fixes golang#8088.

LGTM=iant, r, rsc
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/142320043
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jun 26, 2018
Not a language change.

Several inaccuracies were fixed:

1) A variable declaration may declare more than just one
variable.

2) Variable initialization follows the rules of assignments,
including n:1 assignments. The existing wording implied a 1:1
or n:n rule and generally was somewhat unspecific.

3) The rules for variable declarations with no types and
untyped initialization expressions had minor holes (issue 8088).

4) Clarified the special cases of assignments of untyped values
(we don't just have untyped constants, but also untyped bools,
e.g. from comparisons). The new wording is more direct.

To that end, introduced the notion of an untyped constant's
"default type" so that the same concept doesn't have to be
repeatedly introduced.

Fixes golang#8088.

LGTM=iant, r, rsc
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/142320043
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 9, 2018
Not a language change.

Several inaccuracies were fixed:

1) A variable declaration may declare more than just one
variable.

2) Variable initialization follows the rules of assignments,
including n:1 assignments. The existing wording implied a 1:1
or n:n rule and generally was somewhat unspecific.

3) The rules for variable declarations with no types and
untyped initialization expressions had minor holes (issue 8088).

4) Clarified the special cases of assignments of untyped values
(we don't just have untyped constants, but also untyped bools,
e.g. from comparisons). The new wording is more direct.

To that end, introduced the notion of an untyped constant's
"default type" so that the same concept doesn't have to be
repeatedly introduced.

Fixes golang#8088.

LGTM=iant, r, rsc
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/142320043
wheatman pushed a commit to wheatman/go-akaros that referenced this issue Jul 30, 2018
Not a language change.

Several inaccuracies were fixed:

1) A variable declaration may declare more than just one
variable.

2) Variable initialization follows the rules of assignments,
including n:1 assignments. The existing wording implied a 1:1
or n:n rule and generally was somewhat unspecific.

3) The rules for variable declarations with no types and
untyped initialization expressions had minor holes (issue 8088).

4) Clarified the special cases of assignments of untyped values
(we don't just have untyped constants, but also untyped bools,
e.g. from comparisons). The new wording is more direct.

To that end, introduced the notion of an untyped constant's
"default type" so that the same concept doesn't have to be
repeatedly introduced.

Fixes golang#8088.

LGTM=iant, r, rsc
R=r, rsc, iant, ken
CC=golang-codereviews
https://golang.org/cl/142320043
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation Issues describing a change to documentation. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

5 participants