Skip to content

Commit

Permalink
Actually fix Cause equality (#2654)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikearnaldi committed Apr 29, 2024
1 parent e79cb83 commit f4ed306
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/itchy-carrots-fold.md
@@ -0,0 +1,5 @@
---
"effect": patch
---

Actually fix Cause equality
9 changes: 3 additions & 6 deletions packages/effect/src/internal/cause.ts
Expand Up @@ -686,26 +686,23 @@ const evaluateCause = (
break
}
case OpCodes.OP_FAIL: {
_parallel = HashSet.add(_parallel, cause._tag)
_parallel = HashSet.add(_parallel, cause.error)
_parallel = HashSet.add(_parallel, Chunk.make(cause._tag, cause.error))
if (stack.length === 0) {
return [_parallel, _sequential]
}
cause = stack.pop()
break
}
case OpCodes.OP_DIE: {
_parallel = HashSet.add(_parallel, cause._tag)
_parallel = HashSet.add(_parallel, cause.defect)
_parallel = HashSet.add(_parallel, Chunk.make(cause._tag, cause.defect))
if (stack.length === 0) {
return [_parallel, _sequential]
}
cause = stack.pop()
break
}
case OpCodes.OP_INTERRUPT: {
_parallel = HashSet.add(_parallel, cause._tag)
_parallel = HashSet.add(_parallel, cause.fiberId as unknown)
_parallel = HashSet.add(_parallel, Chunk.make(cause._tag, cause.fiberId as unknown))
if (stack.length === 0) {
return [_parallel, _sequential]
}
Expand Down
6 changes: 6 additions & 0 deletions packages/effect/test/Cause.test.ts
Expand Up @@ -363,5 +363,11 @@ describe("Cause", () => {

it("equals keep account for the failure type", () => {
expect(Equal.equals(Cause.die(0), Cause.fail(0))).toBe(false)
expect(
Equal.equals(
Cause.parallel(Cause.fail("fail1"), Cause.die("fail2")),
Cause.parallel(Cause.fail("fail2"), Cause.die("fail1"))
)
).toBe(false)
})
})

0 comments on commit f4ed306

Please sign in to comment.