-
-
Notifications
You must be signed in to change notification settings - Fork 3k
[mypyc] Support ERR_ALWAYS #9073
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
Conversation
I find the way we deal with Suppose we build an assignment op following the CallC via the call_c function(just like we build a truncate after a CallC)
However, the exception branch is generated directly following the CallC, so after the transform, it would be:
which clearly does not meet our goals. @JukkaL |
Hmm, the proposal we discussed today doesn't seem to work. Here's another idea. Update exception transform to generate the Op for |
I think this is ready for its first-round review @JukkaL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great. Couple requests for comment tweaks
mypyc/primitives/exc_ops.py
Outdated
from mypyc.ir.rtypes import bool_rprimitive, object_rprimitive, void_rtype, exc_rtuple | ||
from mypyc.primitives.registry import ( | ||
simple_emit, call_emit, call_void_emit, call_and_fail_emit, custom_op, | ||
simple_emit, call_emit, call_void_emit, call_and_fail_emit, custom_op, c_custom_op | ||
) | ||
|
||
# If the argument is a class, raise an instance of the class. Otherwise, assume | ||
# that the argument is an exception object, and raise it. | ||
# | ||
# TODO: Making this raise conditionally is kind of hokey. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop this TODO comment, since this is fixing it
elif op.error_kind == ERR_ALWAYS: | ||
variant = Branch.BOOL_EXPR | ||
negated = True | ||
tmp = LoadInt(0, rtype=bool_rprimitive) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment that this is kind of a hack?
It's nice to finally have this! |
related mypyc/mypyc#734, with a focus on exceptions related ops.
This PR adds a new error kind:
ERR_ALWAYS
, which indicates the op always fail.It adds temporary false value to ensure such behavior and makes the raise op void.