Skip to content

Commit bd08028

Browse files
Fix NoSuchElementException instantiation in fastPath in FiberRuntime (#5874)
1 parent 18783c9 commit bd08028

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.changeset/nice-socks-lead.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"effect": patch
3+
---
4+
5+
Fix NoSuchElementException instantiation in fastPath and add corresponding test case

packages/effect/src/internal/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ const fastPath = <A, E, R>(effect: Effect.Effect<A, E, R>): Exit.Exit<A, E> | un
259259
}
260260
case "None": {
261261
// @ts-expect-error
262-
return core.exitFail(core.NoSuchElementException())
262+
return core.exitFail(new core.NoSuchElementException())
263263
}
264264
}
265265
}

packages/effect/test/Effect/sync.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as Cause from "effect/Cause"
44
import * as Effect from "effect/Effect"
55
import * as Exit from "effect/Exit"
66
import { pipe } from "effect/Function"
7+
import * as Option from "effect/Option"
78

89
const sum = (n: number): number => {
910
if (n < 0) {
@@ -23,6 +24,10 @@ describe("Effect", () => {
2324
expect(exit._tag).toBe("Failure")
2425
}
2526
})
27+
it("sync - effect subtype fastPath with NoSuchElementException", () => {
28+
const exit = Effect.runSyncExit(Option.none())
29+
deepStrictEqual(exit, Exit.fail(new Cause.NoSuchElementException()))
30+
})
2631
it.effect("sync - effect", () =>
2732
Effect.gen(function*() {
2833
const sumEffect = (n: number): Effect.Effect<number, unknown> => {

0 commit comments

Comments
 (0)