Skip to content

Commit

Permalink
Update validate_argument_length to catch fewer argumetns error
Browse files Browse the repository at this point in the history
  • Loading branch information
yamakoud committed Dec 13, 2023
1 parent 9ac7ad2 commit 05c654f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/skc_ast2hir/src/convert_exprs/method_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 6 additions & 0 deletions tests/erroneous/method_call/fewer_argument_error.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class A
def self.run(n: Int)
p n
end
end
A.run
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 05c654f

Please sign in to comment.