-
Notifications
You must be signed in to change notification settings - Fork 47
Redshift should raise only StaticErrors #410
Copy link
Copy link
Open
Labels
help wantedExtra attention is neededExtra attention is needed
Description
The following code raises an exception during redshift, but it shouldn't:
def main() -> None:
if False:
1 / 0❯ spy rs /tmp/t.spy
Static error during redshift:
Traceback (most recent call last):
* [redshift] t::main at /tmp/t.spy:3
| 1 / 0
| |___|
ZeroDivisionError: division by zero
On the other hand, this code should continue to raise TypeError eagarly during redshift:
def main() -> None:
if False:
1 + "hello"The difference between the two cases is that TypeError is a subclass of StaticError, while ZeroDivisionError is not.
If a non-StaticError is raised during redshift, it should be turned into the equivalent raise stmt.
In other words, non-StaticError should always behave as if the error mode is set to lazy.
The piece of code responsible for that is here:
Lines 139 to 149 in 3eafa09
| def shift_stmt(self, stmt: ast.Stmt) -> list[ast.Stmt]: | |
| try: | |
| return magic_dispatch(self, "shift_stmt", stmt) | |
| except SPyError as err: | |
| if self.error_mode == "lazy" and err.match(W_StaticError): | |
| # turn the exception into a lazy "raise" statement | |
| self.vm.emit_warning(err) | |
| return self.make_raise_from_SPyError(stmt, err) | |
| else: | |
| # else, just raise the exception as usual | |
| raise |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed