Skip to content
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

x/tools/gopls: show hex/binary literal with which a const was declared on mouse over #47453

Open
soypat opened this issue Jul 29, 2021 · 2 comments
Open

Comments

@soypat
Copy link

@soypat soypat commented Jul 29, 2021

What did you do?

Mouse over a hex/binary notation integer

const hex, bin, oct = 0xe34e, 0b10101, 071

// Mouse over variable name `hex` or `bin` shows decimal representation
c := 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.
@gopherbot gopherbot added this to the Unreleased milestone Jul 29, 2021
@hyangah
Copy link
Contributor

@hyangah hyangah commented Jul 29, 2021

Isn't it a duplicate of #45802? Can you please check if the fix in golang.org/x/tools/gopls@v0.7.1-pre.1 meets what you want?

@soypat
Copy link
Author

@soypat soypat commented Jul 29, 2021

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants