Skip to content

Commit

Permalink
Consider type of failure in Cause equality (#2653)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikearnaldi committed Apr 29, 2024
1 parent 46b1327 commit e79cb83
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-clouds-wash.md
@@ -0,0 +1,5 @@
---
"effect": patch
---

Consider type of failure in Cause equality
3 changes: 3 additions & 0 deletions packages/effect/src/internal/cause.ts
Expand Up @@ -686,6 +686,7 @@ const evaluateCause = (
break
}
case OpCodes.OP_FAIL: {
_parallel = HashSet.add(_parallel, cause._tag)
_parallel = HashSet.add(_parallel, cause.error)
if (stack.length === 0) {
return [_parallel, _sequential]
Expand All @@ -694,6 +695,7 @@ const evaluateCause = (
break
}
case OpCodes.OP_DIE: {
_parallel = HashSet.add(_parallel, cause._tag)
_parallel = HashSet.add(_parallel, cause.defect)
if (stack.length === 0) {
return [_parallel, _sequential]
Expand All @@ -702,6 +704,7 @@ const evaluateCause = (
break
}
case OpCodes.OP_INTERRUPT: {
_parallel = HashSet.add(_parallel, cause._tag)
_parallel = HashSet.add(_parallel, cause.fiberId as unknown)
if (stack.length === 0) {
return [_parallel, _sequential]
Expand Down
4 changes: 4 additions & 0 deletions packages/effect/test/Cause.test.ts
Expand Up @@ -360,4 +360,8 @@ describe("Cause", () => {
assert.strictEqual(Cause.pretty(Cause.fail([{ toString: "" }])), `Error: [{"toString":""}]`)
})
})

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

0 comments on commit e79cb83

Please sign in to comment.