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

Uncaptured locals are not available in closures when debugging #11262

Open
cartermp opened this issue Mar 17, 2021 · 2 comments
Open

Uncaptured locals are not available in closures when debugging #11262

cartermp opened this issue Mar 17, 2021 · 2 comments
Labels
Area-Debug stepping, debug points, stacks and more Feature Improvement 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

@cartermp
Copy link
Contributor

Repro:

  1. Open VisualFSharp.sln
  2. Open SignatureHelp.fs
  3. Put a breakoint on line 123(let startOfArgs = ...)
  4. Launch a hive of VS where you can debug
  5. Enter the following source code:
type C() =
    static member M(x, y, z)  = ()

C.M(1)
  1. Place cursor after the 1 on the last line
  2. Press the comma character (,) so that Signature Help is triggered

Note that there are some locals, and critically you can observe the value of applicableSpan:

image

Now try to get the source code that matches this span by:

  1. Opening the Immediate Window
  2. Entering the following:

sourceText.GetSubText(applicableSpan)

You will observe that sourceText doesn't exist. Indeed, it wasn't even in the locals window.

image

However, note that sourceText is a parameter to this method and it is clearly accessible.

We are losing debug info on every do! call in the method.

To test this, place a breakpoint on line 89 (do! Option.guard (methods.Length > 0 ...). When it is broken there, you'll see that sourceText is available:

image

@cartermp cartermp added Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. Area-Debug stepping, debug points, stacks and more labels Mar 17, 2021
@cartermp cartermp added this to the Backlog milestone Mar 17, 2021
@dsyme
Copy link
Contributor

dsyme commented Aug 16, 2021

This is a general problem with loss of uncaptured variables when debugging F# closures or computation expressions.

In debug mode we should consider simply copying all values into the closure/continuation even if they are not captured.

@cartermp
Copy link
Contributor Author

Yes, absolutely. This would make debugging FSharp.Editor.dll (and other CE-heavy things) so, so much better.

@dsyme dsyme changed the title Debug info lost when debugging complex code in computation expression Uncaptured locals are not available in closures Aug 23, 2021
@dsyme dsyme changed the title Uncaptured locals are not available in closures Uncaptured locals are not available in closures when debugging Aug 23, 2021
@dsyme dsyme added the Theme-Simple-F# A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language. label Feb 16, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Jun 17, 2022
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 Feature Improvement 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

2 participants