Skip to content

Strange order dependency of members with cancellable tasks #15940

Open

Description

@psfinaki

This code:

namespace Microsoft.VisualStudio.FSharp.Editor

open CancellableTasks

type MyType() = class end

[<AutoOpen>]
module MyTypeExtensions =

    type MyType with

        member this.MemberX() =
            cancellableTask {
                return 42
            }

        member this.MemberY() =
            cancellableTask {
                let! result = this.MemberX()
                return result
            }

... compiles just fine:
image

But rearranging the members produces an error:
image

The error being something hard stuff about CE:
image


But this shouldn't be, right? Take vanilla async for example:
image

Activity

  1. added this to the Backlog milestone on Sep 6, 2023
  2. psfinaki commented on Sep 6, 2023

    @psfinaki
    ContributorAuthor

    Poking randomly @TheAngryByrd and @vzarytovskii

  3. vzarytovskii commented on Sep 6, 2023

    @vzarytovskii
    Member

    Async is different, it's classic CE, there's no macro-like behaviour. It's likely due to it being in type augmentation.

  4. TheAngryByrd commented on Sep 6, 2023

    @TheAngryByrd
    Contributor

    I'm guessing it has to do with the mutual recursive type checking behavior of classes and something doesn't apply to state machine CEs. Does it happen with task?

  5. psfinaki commented on Sep 6, 2023

    @psfinaki
    ContributorAuthor

    Nope, tasks are also fine.
    image

  6. TheAngryByrd commented on Sep 6, 2023

    @TheAngryByrd
    Contributor

    hmm what about getting rid of BindReturn and MergeSources for a moment?

    Might also be related to the Source members too.

  7. TheAngryByrd commented on Sep 6, 2023

    @TheAngryByrd
    Contributor

    hmm adding : CancellationToken -> Task<int> to MemberX makes it go away, so related to some weird inferencing.

  8. psfinaki commented on Sep 6, 2023

    @psfinaki
    ContributorAuthor

    Alright so then I guess this at least counts as a bug not feature :)

  9. added
    Impact-Low
    Area-Compiler-StateMachines
    and removed on Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-StateMachinesBugImpact-Low

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions