mirror of
https://github.com/Effect-TS/effect.git
synced 2026-12-04 03:35:36 +08:00
Fix NoSuchElementException instantiation in fastPath in FiberRuntime (#5874)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"effect": patch
|
||||
---
|
||||
|
||||
Fix NoSuchElementException instantiation in fastPath and add corresponding test case
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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> => {
|
||||
|
||||
Reference in New Issue
Block a user