-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
doAssertRaises: stmt
catch all, including foreign exceptions
#15940
doAssertRaises: stmt
catch all, including foreign exceptions
#15940
Conversation
But it violates the spec... Also, why do we need it? If you write a test case with |
because this won't work with foreign exceptions as I explained in #15765 (comment) (see P2)
I'm not sure which section of spec explicitly forbids this case but I think you'll agree the spec should allow overriding in this case:
EDIT: I just remembered #14827 ; let me think whether EDIT: https://nim-lang.github.io/Nim/manual.html#overloading-resolution-lazy-type-resolution-for-untyped says: "But one has to watch out because other overloads might trigger the argument's resolution:" |
But those work with |
no: when defined case2:
{.emit:"""
#include <stdexcept>
void fn(){throw std::runtime_error("asdf");}""".}
proc fn(){.importcpp.}
doAssertRaises(void): fn() gives: Error: only a 'ref object' can be raised (note that in 1st commit of #15765 (see ab6dc1f) I was supporting |
e22d1f4
to
91834fa
Compare
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
this PR adds an overload for
doAssertRaises
that catches all exceptions (including foreign ones which wasn't possible before this PR withdoAssertRaises
, which is useful for cpp and js backends):doAssertRaises: fn()
except Exception as e
#15765#15765 (comment)
overloading works in this case, each overload has a distinct number of non-optional parameters; tests check for this.