Skip to content

case-wrap == operators for strictCaseObjects#61

Open
aryonoco wants to merge 1 commit into
arnetheduck:masterfrom
aryonoco:upstream-case-wrap-eq
Open

case-wrap == operators for strictCaseObjects#61
aryonoco wants to merge 1 commit into
arnetheduck:masterfrom
aryonoco:upstream-case-wrap-eq

Conversation

@aryonoco
Copy link
Copy Markdown

The three Result `==` overloads used `if lhs.o != rhs.o: false; else: case lhs.o of true: lhs.v == rhs.v of false: lhs.e == rhs.e`. Under strictCaseObjects, the `rhs.v` / `rhs.e` reads are rejected because only `lhs.o` was discriminated; the implicit equality between lhs.o and rhs.o (from the outer if) is not tracked across branches by strict's flow analysis.

Restructure each overload with nested `case` on both operands independently so every variant-field read is inside a proving `of` branch. Identical runtime behaviour; strict-clean at generic instantiation sites.

Three overloads rewritten:

  • `Result[T0, E0] == Result[T1, E1]` (non-void T, non-void E)
  • `Result[void, E0] == Result[void, E1]`
  • `Result[T0, void] == Result[T1, void]`

The three Result `==` overloads used `if lhs.o != rhs.o: false;
else: case lhs.o of true: lhs.v == rhs.v of false: lhs.e == rhs.e`.
Under strictCaseObjects, the `rhs.v` / `rhs.e` reads are rejected
because only `lhs.o` was discriminated; the implicit equality
between lhs.o and rhs.o (from the outer if) is not tracked across
branches by strict's flow analysis.

Restructure each overload with nested `case` on both operands
independently so every variant-field read is inside a proving `of`
branch. Identical runtime behaviour; strict-clean at generic
instantiation sites.

Three overloads rewritten:
  * `Result[T0, E0] == Result[T1, E1]` (non-void T, non-void E)
  * `Result[void, E0] == Result[void, E1]`
  * `Result[T0, void] == Result[T1, void]`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant