Skip to content

Failed pattern match at Effect.Aff #159

Closed
@felixSchl

Description

@felixSchl

The following code causes an uncaught exception to be thrown:

  bracket
    (do
      v <- AVar.empty
      v <$ do
        liftEffect $ launchAff_ do
          delay $ 1.0 # Milliseconds
          AVar.kill (error "boom") v
    )
    (\_ _ ->
      void $ attempt $ pure unit
    )
    \v ->
      forever $ AVar.take v
/home/felix/projects/aff-bug/output/Effect.Aff/index.js:76
        throw new Error("Failed pattern match at Effect.Aff line 385, column 12 - line 387, column 20: " + [ v.constructor.name ]);
                                                                                                               ^

TypeError: Cannot read property 'constructor' of null
    at Object.isLeft (/home/felix/projects/aff-bug/output/Effect.Aff/index.js:76:112)
    at run (/home/felix/projects/aff-bug/output/Effect.Aff/foreign.js:508:27)
    at /home/felix/projects/aff-bug/output/Effect.Aff/foreign.js:333:19
    at drain (/home/felix/projects/aff-bug/output/Effect.Aff/foreign.js:120:9)
    at Object.enqueue (/home/felix/projects/aff-bug/output/Effect.Aff/foreign.js:141:11)
    at Timeout._onTimeout (/home/felix/projects/aff-bug/output/Effect.Aff/foreign.js:330:27)
    at ontimeout (timers.js:466:11)
    at tryOnTimeout (timers.js:304:5)
    at Timer.listOnTimeout (timers.js:267:5)

The error goes away in one of two conditions:

  • don't AVar.take in the run handler
  • don't use attempt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions