language-service icon indicating copy to clipboard operation
language-service copied to clipboard

Suggest returning yield* with Effect.fail inside Effect.gen

Open mattiamanzati opened this issue 8 months ago • 1 comments

What is the problem this feature would solve?

Would prevent things such as

const program = (key: string) =>
    Effect.gen(function*() {
        const remoteConfig = yield* Effect.tryPromise(() =>
        );

        if (isUndefined(defaultValue) || !hasProperty(defaultValue, "value")) {
            yield* Effect.fail(
                new RemoteConfigError({
                    cause: `Remote config key '${key}' not found`,
                }),
            );
        }

        return defaultValue.value;
    });

What is the feature you are proposing to solve the problem?

Emit a warning diagnostic

What alternatives have you considered?

No response

mattiamanzati avatar Apr 22 '25 14:04 mattiamanzati

BTW some Yieldable structures can be supported in advance - Option, Either etc and Option.gen & Either.gen contexts

KhraksMamtsov avatar Apr 22 '25 15:04 KhraksMamtsov