Skip to content

Regression: Effect.all with struct of effects breaks Effect.filterOrFail #5078

@jfet97

Description

@jfet97

What version of Effect is running?

3.16.8

What steps can reproduce the bug?

import { Effect, Schema } from "effect"
import { TaggedError } from "effect/Schema"

class InvalidStateError extends TaggedError<InvalidStateError>()("InvalidStateError", {
  message: Schema.String
}) {}

Effect.all({
  valid: Effect.filterOrFail(
    Effect.succeed({ id: "123", displayName: "" }),
    (user) => !user.displayName,
    (_) => new InvalidStateError({ message: "User has no displayName!" })
  )
})

What is the expected behavior?

The program should type-check successfully.

What do you see instead?

The call to Effect.filterOrFail gives: No overload matches this call.

Additional information

Storing the Effect.filterOrFail result in a variable to the apply Effect.all does not trigger the error. So it is the direct combination of the two which causes problems.

import { Effect, Schema } from "effect"
import { TaggedError } from "effect/Schema"

class InvalidStateError extends TaggedError<InvalidStateError>()("InvalidStateError", {
  message: Schema.String
}) {}

// equivalent version which type-checks

const this_is_ok = Effect.filterOrFail(
  Effect.succeed({ id: "123", displayName: "" }),
  (user) => !user.displayName,
  (_) => new InvalidStateError({ message: "User has no displayName!" })
)

Effect.all({
  valid: this_is_ok
})

Repro: https://effect.website/play#73a99125caa6.
Was fine with Effect 3.14.20.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions