delve icon indicating copy to clipboard operation
delve copied to clipboard

To report variable declaration column

Open nd opened this issue 5 years ago • 7 comments

It would be nice if delve reported DeclColumn in addition to DeclLine for variables. This would allow a front-end to sort variables in a declaration order and handle multi-variable declarations as well as function arguments/named returns.

nd avatar Mar 21 '19 10:03 nd

debug_info doesn't have that and IMHO adding it wouldn't be worth the binary size inflation. Function arguments are already returned sorted in their declaration order (at least in 1.12, there was a bug in either 1.10 or 1.11, don't remember).

aarzilli avatar Mar 21 '19 16:03 aarzilli

Do I understand correctly that multiple declarations on the line are also returned by delve in declaration order? Quick test confirms that for b, a := 1, 1 in 1.12.1. Is it always the case or only a coincidence?

nd avatar Mar 22 '19 15:03 nd

Discovered that it's not guaranteed, e.g. for doesn't work for b, c, a := 1, 1, 1

nd avatar Mar 22 '19 16:03 nd

Only function arguments, but IMHO that's 90% of usecases anyway.

aarzilli avatar Mar 29 '19 07:03 aarzilli

@aarzilli if we file a request upstream for the compiler to write these in order, then would it be possible for Delve to return them in order? If yes, then I guess it would satisfy both the original request and the debugging binary size.

dlsniper avatar Mar 29 '19 07:03 dlsniper

if we file a request upstream for the compiler to write these in order, then would it be possible for Delve to return them in order?

I believe it would happen automatically.

aarzilli avatar Mar 29 '19 07:03 aarzilli

Reported here: https://github.com/golang/go/issues/31133

dlsniper avatar Mar 29 '19 09:03 dlsniper