consthex, bin, oct=0xe34e, 0b10101, 071// Mouse over variable name `hex` or `bin` shows decimal representationc:=hex*bin
What did you expect to see?
The literal used to declare the const. Usually when one declares a const in hex, binary or octal representation it carries with it a significance, to aid the reader of the code. If we wrote programs for machines gofmt would convert these literals to decimals or whatever the computer like.
With the philosophy out of the way, I expected to see:
const hex untyped int = 0xe34e (58190)
const bin untyped int = 0b10101 (21).
What did you see instead?
The usual gopls help string of
const hex untyped int = 58190
const bin untyped int = 21.
The text was updated successfully, but these errors were encountered:
@hyangah negative. The issues are similar in nature though. I'm not asking for literal evaluation but rather that gopls show me how the author initialized a const integer since there are around 5 ways of initializing the same number and usually non-decimal form carries useful information about certain bits (i.e. bitfields, masks)
…iables and constants
This change improves the hover information for variables and constants by showing
both an original declaration and a value. The value is shown as an inline comment.
Two kinds of declarations are currently supported:
1. Basic literals of type int:
* var x int64 = 0xff // 255
* const x untyped int = 0b11 // 3
* const x uint = 1_000_000 // 1000000
2. Binary expressions with bitwise operators:
* var x uint = 0b10 | 0b1 // 3
* const x untyped int = 10 << 20 // 10485760
This change also removes TestHoverIntLiteral in favor of marker tests