Fix NoSuchElementException instantiation in fastPath in FiberRuntime (#5874)

This commit is contained in:
Mattia Manzati
2025-12-06 18:18:34 +01:00
committed by GitHub
parent 18783c9855
commit bd080284fe
3 changed files with 11 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"effect": patch
---
Fix NoSuchElementException instantiation in fastPath and add corresponding test case
+1 -1
View File
@@ -259,7 +259,7 @@ const fastPath = <A, E, R>(effect: Effect.Effect<A, E, R>): Exit.Exit<A, E> | un
}
case "None": {
// @ts-expect-error
return core.exitFail(core.NoSuchElementException())
return core.exitFail(new core.NoSuchElementException())
}
}
}
+5
View File
@@ -4,6 +4,7 @@ import * as Cause from "effect/Cause"
import * as Effect from "effect/Effect"
import * as Exit from "effect/Exit"
import { pipe } from "effect/Function"
import * as Option from "effect/Option"
const sum = (n: number): number => {
if (n < 0) {
@@ -23,6 +24,10 @@ describe("Effect", () => {
expect(exit._tag).toBe("Failure")
}
})
it("sync - effect subtype fastPath with NoSuchElementException", () => {
const exit = Effect.runSyncExit(Option.none())
deepStrictEqual(exit, Exit.fail(new Cause.NoSuchElementException()))
})
it.effect("sync - effect", () =>
Effect.gen(function*() {
const sumEffect = (n: number): Effect.Effect<number, unknown> => {