go/types, go/constant: improve documentation on constant.Kind and relationship to concrete types #45906
Labels
Documentation
Issues describing a change to documentation.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
ISTM that go/types and go/constant don't currently do a good job at explaining which constant.Kind can be encountered in which contexts. For example, before seeing #43891 I wasn't aware that a floating point constant may have Kind() == Int.
And while that issue explains that go/constant may use a more efficient representation, it doesn't mention if it may use a less efficient representation, especially in relationship with the type checker. For example, in the following example
it is not clear to me whether the types.TypeAndValue for the ast.Ident
k
as used in the bit shift and function call are guaranteed to be a constant.Int or not. It currently seems to be, and existing code invet
doesn't defensively use ToInt before using Uint64ValSummarizing, I'd like to see documentation that at least
/cc @griesemer
The text was updated successfully, but these errors were encountered: