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
spec: integer and floating point types are not explicitly defined #49804
Comments
cc @griesemer |
Thanks for the issue. This is a known concern and on the list of things to be addressed for the Go 1.18 spec because we need to expand the terminology to incorporate type parameters that act as "integers" or "floats". |
Ok, thank you. Shall I close? |
No, please leave it open. Thanks. |
@griesemer This is in the 1.18 milestone; time to move to 1.19? Thanks. |
This is now addressed in the latest spec: The section on numeric types explicitly introduces the terms. |
In go1.17_spec.html lines 866 to 890 the notion of (predeclared) numerical types is defined by defining each of these (predeclared) numerical types individually. However, integer types and floating-point types are not defined.
Nevertheless, throughout the specification the notion of an integer type is used in the specification of the language (e.g. in lines 2530, 3128, 3600, 4234, 4375, 5939, 6731, 6793 and 6816) and similarly, the notion of a floating-point type is used in the specification of the language, too ( e.g. in lines 1686, 3819, 4245, 6084 and (in an example) 6121).
Even though for experienced programmers it is clear from context what integer types and floating point types are, after numerical types have been defined, there is actually some ambiguity. Whether for example in the language specification indexing by integer types includes includes indexing by
int32
, too, or unsigned integer types. Additionally, the officially recommended debugger dlv does not recognize indexing byuint32
when using the commandprint
(which likely is a bug in dlv, though), whereas the official compiler as of version go1.16.2 and the compiler of the go playground do (see example below).If writing safe code is of concern, then I even prefer to assume, that indexing by non-
int
types is a feature of the compiler and not the language itself.What version of Go are you using (
go version
)?The problem is in the The Go Programming Language Specification Version of Jul 26, 2021.
Does this issue reproduce with the latest release?
Yes. (Also see example below.)
What operating system and processor architecture are you using (
go env
)?go env
OutputExample for indexing with several different non-
int
types:See https://go.dev/play/p/QpKQtOK4F-j
What did you expect to see?
Unclear, because the problem is the ambiguity of the go spec.
The text was updated successfully, but these errors were encountered: