Skip to content

Commit 782d53f

Browse files
author
t3tra
authored
Merge pull request #39 from t3tra-dev/feat/eh
2 parents 3c023a6 + 5dc40bc commit 782d53f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/lython/visitors/expr.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ def visit_Call(self, node: ast.Call) -> ir.Value | None:
549549
func_info = self.lookup_function(node.func.id)
550550
result_types = list(func_info.result_types)
551551
if func_info.maythrow:
552+
self._note_maythrow()
552553
if result_types != [self.get_py_type("!py.none")]:
553-
self._note_maythrow()
554554
raise NotImplementedError(
555555
"py.invoke for value-returning calls is not implemented yet"
556556
)
@@ -647,6 +647,8 @@ def _handle_class_instantiation(
647647
# Call __init__ if it exists
648648
if "__init__" in class_info.methods:
649649
init_info = class_info.methods["__init__"]
650+
if init_info.maythrow:
651+
self._note_maythrow()
650652
# __init__ args are (self, *args) - self is already the instance
651653
init_args = [instance] + arg_values
652654
posargs = self.build_tuple(init_args, loc=loc)
@@ -704,6 +706,8 @@ def _handle_method_call(self, node: ast.Call, loc: ir.Location) -> ir.Value:
704706
raise AttributeError(f"Class '{class_name}' has no method '{method_name}'")
705707

706708
method_info = class_info.methods[method_name]
709+
if method_info.maythrow:
710+
self._note_maythrow()
707711

708712
with loc, self.insertion_point():
709713
# Build args tuple with self as first argument

0 commit comments

Comments
 (0)