go-delve / delve

Delve is a debugger for the Go programming language.
MIT License
22.38k stars 2.13k forks source link

pkg/proc: implement composite literals #3691

Closed firelizzard18 closed 3 months ago

firelizzard18 commented 3 months ago

This change implements composite literals for struct, slice, array, and map types.

Fixes #1465

firelizzard18 commented 3 months ago

My use case is the original ask in #1465 - accessing map elements (e.g. a watch expression in vscode). I'm not sure how much value there is in map and slice literals (since those can't me map keys). The map literals my code makes are at least somewhat broken - they can't be iterated since Variable.Addr is zero. I'm not sure how much else is broken.

firelizzard18 commented 3 months ago

I assume it's the Variable construction in (*EvalScope).evalCompositeLit that's broken? Should I close this PR?

aarzilli commented 3 months ago

Basically, you are creating a Variable that can only be used in very specific expressions. As I said, there isn't a really way to make this work properly, at the moment. Sorry.

firelizzard18 commented 3 months ago

As I said, there isn't a really way to make this work properly, at the moment.

Sure, I get that and I'm not surprised my 'solution' doesn't work. I'm not clear on what you'd prefer to do with this PR: close it or leave it open/as a draft until it can be done properly. It doesn't make much of a difference to me either way.

aarzilli commented 3 months ago

You should close it, I already have a version privately that does this with the allocation and it's very different from this.