spec: a valid range uint(maxUint) is not accepted #66967
Labels
Documentation
Issues describing a change to documentation.
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Per the spec:
yet the following program is accepted (playground):
The range expression
uint(maxUint)
is an integer expression but cannot be assigned to an int variable, yet this code is permitted. Or perhaps the intent was that the assignability requirement toint
is only present if the expressionx
is untyped, but it's not super-clear from the prose. Furthermore, it doesn't say anything about rune constantsx
.In general, an (integer) numeric range expression x produces the index values from 0, 1, ... x-1 and so we want the same type behavior as we get in assignments. If the index variable i is:
i = x
must be validi := x
must be valid (but we may want to allow floating point constantsx
representable asint
values_ = x
must be validThe spec needs to be updated accordingly.
The text was updated successfully, but these errors were encountered: