Skip to content

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

@dsyme

Description

@dsyme

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Debugstepping, debug points, stacks and moreBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions