Skip to content

Extra out-of-order sequence point for use in task computation expressions #19255

@auduchinok

Description

@auduchinok
let disposable =
    { new IDisposable with member this.Dispose() = () }

let t =
    task {
        let i = 1
        use encryptor = disposable
        return 1
    }

t.Result

It's expected that there are 3 non-hidden sequence points inside the task expression.
However, excluding the hidden sequence points, the MoveNext method contains these sequence points:

Offset 7, (7, 9) - (7, 35)
Offset 8, (6, 9) - (6, 18)
Offset 10, (7, 9) - (7, 12)
Offset 28, (8, 9) - (8, 15)

There's an extra sequence point inserted for the use binding before the other sequence points, and it only consist of a single nop instruction.

This extra sequence point may significantly worsen the debugging experience, because it gives an impression that the code is executed in a wrong order:

  • line 7 (nop)
  • line 6 (let i)
  • line 7 (actual use code)
  • line 8 (return)

Workaround: not using use bindings in task expressions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Debugstepping, debug points, stacks and moreBug

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions