Skip to content

case-wrap raise* helpers for strictCaseObjects#60

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

case-wrap raise* helpers for strictCaseObjects#60
aryonoco wants to merge 1 commit into
arnetheduck:masterfrom
aryonoco:upstream-case-wrap-raise

Conversation

@aryonoco
Copy link
Copy Markdown

Rewrites `raiseResultOk` and `raiseResultError` to dispatch on `oResultPrivate` via `case`, avoiding `{.cast(uncheckedAssign).}` (which does not suppress read-side strict checks and is unavailable on Nim < 1.6). The `when E is void` branch of `raiseResultError` is hoisted above the new case to keep the non-void body from instantiating on the void specialisation (where `eResultPrivate` does not exist).

The unreachable-by-contract fallback branches raise `ResultError[void]` to satisfy `{.noreturn.}`; this matches the type raised by adjacent reachable branches and avoids a forward reference to `raiseResultDefect`.

Rewrite raiseResultOk and raiseResultError to dispatch on
oResultPrivate via `case`, avoiding {.cast(uncheckedAssign).}
(which does not suppress read-side strict checks and is unavailable
on Nim < 1.6). The `when E is void` branch of raiseResultError is
hoisted above the new case so the non-void body does not
instantiate on the void specialisation, where eResultPrivate does
not exist.

The unreachable-by-contract fallback branches raise
ResultError[void] to satisfy {.noreturn.}; this matches the type
raised by adjacent reachable branches and avoids a forward
reference to raiseResultDefect.
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