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

In debugging, arguments are always shown instead of locals #12409

Open
dsyme opened this issue Nov 16, 2021 · 3 comments
Open

In debugging, arguments are always shown instead of locals #12409

dsyme opened this issue Nov 16, 2021 · 3 comments
Labels
Area-Debug stepping, debug points, stacks and more Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Milestone

Comments

@dsyme
Copy link
Contributor

dsyme commented Nov 16, 2021

Given this:

let inp = seq { 1 .. 3 }
let h3 x =
    for x in inp do
       printfn $"hello, x = {x}"
       printfn "hello"

h3 10

then when you stop inside the loop, the value x shows as 10 even though in the loop it is 1, 2, 3. The locals simply aren't shown at all.

I'm not actually sure there is a fix to this without #2544 knowing how to resolve the names according to F# rules. It looks to me like the C# locals display is simply deciding not to show any locals that conflict with an argument name (which they never do according to C# rules)

Note this may have changed in recent VS, I've not seen the problem before, though it's likely it's just always been there.

@dsyme dsyme added Bug Area-Debug stepping, debug points, stacks and more Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language. Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. labels Nov 16, 2021
@dsyme
Copy link
Contributor Author

dsyme commented Nov 16, 2021

Note that in the "watch" window the value "x" displays correctly, as does hovering over "x". So it's only the debug locals window which is strange.

@baronfel
Copy link
Member

image

Same results in both cases on VSCode for me. I'd expect this, given it's (IIRC) all the same expression evaluator, but just wanted to toss in my results.

@dsyme
Copy link
Contributor Author

dsyme commented Nov 17, 2021

I can confirm this is in VS2019 as well, and is not related to any changes in the F# compiler, it's just always been like this.

There is unfortunately no way to specify scopes for arguments in the .NET PDB format, so we can't workaround this through clever PDB emit, and can't give the "(shadowed)" names to the arguments when they're out of scope.

It's strange that the debugger engine just completely ignores actual locals that conflict with arguments (since it is fine with showing multiple locals with the same name). It may be an easy fix to the debugger engine that doesn't affect C# at all, though it would be much better if we just implemented a debugger engine for F#.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Debug stepping, debug points, stacks and more Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.
Projects
Status: New
Development

No branches or pull requests

3 participants