Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lython/visitors/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,8 @@ def visit_Call(self, node: ast.Call) -> ir.Value | None:
func_info = self.lookup_function(node.func.id)
result_types = list(func_info.result_types)
if func_info.maythrow:
self._note_maythrow()
if result_types != [self.get_py_type("!py.none")]:
self._note_maythrow()
raise NotImplementedError(
"py.invoke for value-returning calls is not implemented yet"
)
Expand Down Expand Up @@ -647,6 +647,8 @@ def _handle_class_instantiation(
# Call __init__ if it exists
if "__init__" in class_info.methods:
init_info = class_info.methods["__init__"]
if init_info.maythrow:
self._note_maythrow()
# __init__ args are (self, *args) - self is already the instance
init_args = [instance] + arg_values
posargs = self.build_tuple(init_args, loc=loc)
Expand Down Expand Up @@ -704,6 +706,8 @@ def _handle_method_call(self, node: ast.Call, loc: ir.Location) -> ir.Value:
raise AttributeError(f"Class '{class_name}' has no method '{method_name}'")

method_info = class_info.methods[method_name]
if method_info.maythrow:
self._note_maythrow()

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