diff --git a/guppylang/checker/func_checker.py b/guppylang/checker/func_checker.py index 7463cf7b..c684aac3 100644 --- a/guppylang/checker/func_checker.py +++ b/guppylang/checker/func_checker.py @@ -176,6 +176,10 @@ def check_signature(func_def: ast.FunctionDef, globals: Globals) -> FunctionType raise GuppyError(UnsupportedError(func_def.args.vararg, "Variadic args")) if func_def.args.kwarg is not None: raise GuppyError(UnsupportedError(func_def.args.kwarg, "Keyword args")) + if func_def.args.defaults: + raise GuppyError( + UnsupportedError(func_def.args.defaults[0], "Default arguments") + ) if func_def.returns is None: err = MissingReturnAnnotationError(func_def) # TODO: Error location is incorrect diff --git a/tests/error/misc_errors/default_arg.err b/tests/error/misc_errors/default_arg.err new file mode 100644 index 00000000..9de36146 --- /dev/null +++ b/tests/error/misc_errors/default_arg.err @@ -0,0 +1,8 @@ +Error: Unsupported (at $FILE:5:26) + | +3 | +4 | @compile_guppy +5 | def foo(x: int, y: bool = True) -> int: + | ^^^^ Default arguments are not supported + +Guppy compilation failed due to 1 previous error diff --git a/tests/error/misc_errors/default_arg.py b/tests/error/misc_errors/default_arg.py new file mode 100644 index 00000000..a4eacc97 --- /dev/null +++ b/tests/error/misc_errors/default_arg.py @@ -0,0 +1,6 @@ +from tests.util import compile_guppy + + +@compile_guppy +def foo(x: int, y: bool = True) -> int: + return x