Skip to content

Uncaptured locals are not available in closures when debugging #11262

@cartermp

Description

@cartermp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Debugstepping, debug points, stacks and moreFeature ImprovementImpact-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.

    Type

    No type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions