diff --git a/guppylang/checker/expr_checker.py b/guppylang/checker/expr_checker.py index 5a829d58..ca5f03be 100644 --- a/guppylang/checker/expr_checker.py +++ b/guppylang/checker/expr_checker.py @@ -753,6 +753,10 @@ def visit_IfExp(self, node: ast.IfExp) -> tuple[ast.expr, Type]: f"`{ast.unparse(node)}`" ) + def generic_visit(self, node: ast.expr) -> NoReturn: + """Called if no explicit visitor function exists for a node.""" + raise GuppyError(UnsupportedError(node, "This expression", singular=True)) + def check_type_against( act: Type, exp: Type, node: AstNode, kind: str = "expression" diff --git a/tests/error/misc_errors/unsupported_expr.err b/tests/error/misc_errors/unsupported_expr.err new file mode 100644 index 00000000..684b2f37 --- /dev/null +++ b/tests/error/misc_errors/unsupported_expr.err @@ -0,0 +1,8 @@ +Error: Unsupported (at $FILE:7:14) + | +5 | @compile_guppy +6 | def foo(xs: array[int, 1]) -> tuple[int, int]: +7 | return 0, *xs + | ^^^ This expression is not supported + +Guppy compilation failed due to 1 previous error diff --git a/tests/error/misc_errors/unsupported_expr.py b/tests/error/misc_errors/unsupported_expr.py new file mode 100644 index 00000000..27388ede --- /dev/null +++ b/tests/error/misc_errors/unsupported_expr.py @@ -0,0 +1,7 @@ +from guppylang.std.builtins import array +from tests.util import compile_guppy + + +@compile_guppy +def foo(xs: array[int, 1]) -> tuple[int, int]: + return 0, *xs