diff --git a/lib/skc_ast2hir/src/convert_exprs/method_call.rs b/lib/skc_ast2hir/src/convert_exprs/method_call.rs index cfc2f52b..4d87c497 100644 --- a/lib/skc_ast2hir/src/convert_exprs/method_call.rs +++ b/lib/skc_ast2hir/src/convert_exprs/method_call.rs @@ -168,7 +168,7 @@ pub fn arrange_named_args<'a>( /// Check if number of arguments matches to the params. fn validate_argument_length(total_args: usize, params: &[MethodParam]) -> Result<()> { - if total_args > params.len() { + if total_args != params.len() { return Err(error::argument_error(format!( "wrong number of arguments: expected {}, got {}", params.len(), diff --git a/tests/erroneous/method_call/fewer_argument_error.sk b/tests/erroneous/method_call/fewer_argument_error.sk new file mode 100644 index 00000000..1c88ab85 --- /dev/null +++ b/tests/erroneous/method_call/fewer_argument_error.sk @@ -0,0 +1,6 @@ +class A + def self.run(n: Int) + p n + end +end +A.run diff --git a/tests/snapshots/erroneous__erroneous@method_call__fewer_argument_error.sk.snap b/tests/snapshots/erroneous__erroneous@method_call__fewer_argument_error.sk.snap new file mode 100644 index 00000000..63ad26a0 --- /dev/null +++ b/tests/snapshots/erroneous__erroneous@method_call__fewer_argument_error.sk.snap @@ -0,0 +1,6 @@ +--- +source: tests/erroneous.rs +expression: compiler_output +input_file: tests/erroneous/method_call/fewer_argument_error.sk +--- +wrong number of arguments: expected 1, got 0