Skip to content

Debugging match with 'when' causes false stepping point #11977

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

Closed
dsyme opened this issue Aug 16, 2021 · 1 comment
Closed

Debugging match with 'when' causes false stepping point #11977

dsyme opened this issue Aug 16, 2021 · 1 comment
Labels
Area-Debug stepping, debug points, stacks and more Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.

Comments

@dsyme
Copy link
Contributor

dsyme commented Aug 16, 2021

Debugging this code:

type U = 
   | A1 of int
   | A2 of int
   | A3 of int
   | A4 of int

let testFunc f u = 
    match u with 
    | A1 n -> f n
    | A2 n when n > 4 -> f n // this is hit
    | A2 n -> f n
    | A3 n -> f n
    | A4 n -> f n

testFunc id (A3 4)
fsc.exe -g --optimize- --terms --tailcalls- a.fsx 
devenv /debugexe a.exe

and stepping steps through the line "// this is hit" before continuing. THis is a false step - the code f n on that line is never hit.

The cause is that when we split pattern matching into chunks (e.g. A2, A3, A4) here https://github.com/dotnet/fsharp/blob/main/src/fsharp/PatternMatchCompilation.fs#L1419 the "continue" expression doesn't have a debug range. That means its initial code gets the debug range of the "A2 when" clause.

@dsyme dsyme added the Area-Debug stepping, debug points, stacks and more label Aug 16, 2021
@TIHan TIHan added Feature Improvement Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. and removed Feature Improvement labels Aug 18, 2021
@dsyme
Copy link
Contributor Author

dsyme commented Aug 20, 2021

Fixed in #11981

@dsyme dsyme closed this as completed Aug 20, 2021
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-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
None yet
Development

No branches or pull requests

2 participants