Skip to content

Conversation

@aarzilli
Copy link
Member

Fixes #4179

@aarzilli aarzilli force-pushed the fix4179 branch 3 times, most recently from 7895256 to 7a36e78 Compare October 12, 2025 16:27
@aarzilli
Copy link
Member Author

To be honest I'm not sure it's worth doing this. It matches better the semantics of Go but It brings in some complication and it's mostly about collisions between local variables and global variables (which are rare anyway).

@wenxuan70
Copy link
Contributor

This PR seems to address another issue I discovered the other day. When the local structure variable and the package name in dwarf are the same, when calling the method of the local structure variable, it will be displayed that the method cannot be found. 🤣
I'll test it tonight when I have some free time to see if I can solve another problem.

@wenxuan70
Copy link
Contributor

wenxuan70 commented Nov 8, 2025

I tried debugging the unit tests using the Delve command fixed by this patch and found other issues.
When I try to call ctx.Value("ok"), I receive an error message: could not find symbol. This seems to be because the local variable name conflicts with another package of the same name.
I took a cursory look at the dlv source code and its associated fncall logs. When compiling to an ast expression, ctx is replaced by another name.

example:
image

fncall logs:
image

@aarzilli
Copy link
Member Author

What's code.byted.org/gin/ginex/ctx.Value?

@wenxuan70
Copy link
Contributor

the code.byted.org/gin/ginex/ctx is the package name. No code.byted.org/gin/ginex/ctx.Value.

@wenxuan70
Copy link
Contributor

I've determined that this code is causing the problem. But I'm not sure if this scenario makes sense.

delve/pkg/proc/bininfo.go

Lines 3002 to 3009 in b271ba3

if len(bi.PackageMap[x.Name]) > 0 {
// There's no particular reason to expect the first entry to be the
// correct one if the package name is ambiguous, but trying all possible
// expansions of all types mentioned in the expression is complicated
// and, besides type assertions, users can always specify the type they
// want exactly, using a string.
x.Name = bi.PackageMap[x.Name][0]
}

@aarzilli
Copy link
Member Author

Should be fixed.

@wenxuan70
Copy link
Contributor

I used your patch and it worked fine locally.

@derekparker
Copy link
Member

To be honest I'm not sure it's worth doing this. It matches better the semantics of Go but It brings in some complication and it's mostly about collisions between local variables and global variables (which are rare anyway).

I've been holding off on review due to this concern. Do you still feel this way?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong anonymous method shown when local var name matches package name

3 participants