-
Notifications
You must be signed in to change notification settings - Fork 6
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
Allow for a failing test to automatically raise an error #368
Comments
For this case, I would expect to write this:
I'm not sure if this works, but it should. And it does have the benefit of incorporating an error message. I'm not crazy about overloading the question mark this way, but for cases where you don't want to bother with the error message, how about this instead:
I would hope that |
I believe one alternative that works currently is
Which reifies the test, ignoring the succeed/fail The
Actually, as it's a test, why can't it be reified like
That might not work right now, but I don't see why we can't allow it. |
You're right about the I don't see Because |
If a test is called in a det context, the compilation will error. This is good, I hope we can agree.
Sometimes, though, you don't really care about what happens in the failure case, and instead would want to abort the program. Automatically generating such code would reduce boilerplate code written.
Consider the following:
In such a case, we could via some static analysis know that the
head
call cannot fail. Alternatively, as the programmer, we may wish to handle this, but of course make it explicit. Consider this:The preceding
?
says "I know this is a test, and if this fails call!error
". The compiler could automatically generate theif
here, which would allow for the!error
call to have the call position resource set appropriately.While this probably isn't ideal, I think it could be handy if you want to do something in an admittedly hacky way.
The text was updated successfully, but these errors were encountered: