Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

without with error variable works for any Result type #59

Merged
merged 1 commit into from
May 29, 2024

Conversation

markspanbroek
Copy link
Member

These type of statements used to only work for ?!T types:

without x =? y, error:
  # do something with error

Now they also work for any Result[T, E] types, with the caveat that the error is converted to a ref CatchableError.
Conversion is necessary, because we need a type for the error variable that works for any type of result, in case that we have multiple =? bindings in the without expression, e.g.:

var a: ?!int
var b: Result[int, string]

without x =? a and y =? b, error:
  # without conversion error types would clash

@markspanbroek markspanbroek merged commit 3dcf214 into main May 29, 2024
8 checks passed
@markspanbroek markspanbroek deleted the without-with-error-for-any-result branch May 29, 2024 10:45
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