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

Inconsistent hex representation of typed constants with unsigned int type #3485

Closed
corneliusweig opened this issue Aug 29, 2023 · 1 comment · Fixed by #3487
Closed

Inconsistent hex representation of typed constants with unsigned int type #3485

corneliusweig opened this issue Aug 29, 2023 · 1 comment · Fixed by #3487

Comments

@corneliusweig
Copy link

  1. What version of Delve are you using (dlv version)? 1.21.0
  2. What version of Go are you using? (go version)? 1.21
  3. What operating system and processor architecture are you using? Linux
  4. What did you do? Debug the following program in VS Code, using Delve's DAP adapter:
package main

import "fmt"

type A uint32

const (
	zero = A(iota)
	one
	two
)

func main() {
	a := zero
	b := one
	c := two
	d := A(3)
	e := A(4)
	fmt.Println(a, b, c, d, e)  // halt here
}

In particular, the program defines a new type with an underlying unsigned int type and a few constants of that type.

  1. What did you see instead?

The hex representation of values of type A is inconsistent with the numeric value. This only happens for unsigned int types, and as long as the value can be represented as a binary OR of predefined constants of that type:
image

The expected representation should be:

a: zero (0) = 0x0
b: one (1) = 0x1
c: two (2) = 0x2
d: one|two (3) = 0x3
e: 4 = 0x4
aarzilli added a commit to aarzilli/delve that referenced this issue Aug 29, 2023
Fix hexadecimal printing of variables that can be represented using
symbolic const values in DAP as well as the command line interface.

Fixes go-delve#3485
derekparker pushed a commit that referenced this issue Aug 29, 2023
…3487)

Fix hexadecimal printing of variables that can be represented using
symbolic const values in DAP as well as the command line interface.

Fixes #3485
@corneliusweig
Copy link
Author

Thank you for this awesomely quick fix!

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

Successfully merging a pull request may close this issue.

2 participants