Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): missing function parameters #461

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
13 changes: 13 additions & 0 deletions src/tests/validity/function_optional_argument_array.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Output
// 1100

fun sum_array(a : [Num] = [Num]): Num {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the default value a type? Doesn't it raise any errors while compiling?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No doesn't, those are the tests for that feature that were missing after implement the feature.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still dont understand this. Why do we allow for type to be a default value? What is the usecase?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, I just migrated the test from the PR that was approved and were missing in the actual codebase.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this test succeeds, this is worth opening an issue about.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests right now works, if someone want to open a ticket about it to me is fine :-)

let sum = 0
loop n in a {
sum += n;
}
return sum;
}
let x = [100,1000]
let result = sum_array(x)
echo "1100"
12 changes: 12 additions & 0 deletions src/tests/validity/function_optional_argument_array_default.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Output
// 1000

fun sum_array(a : [Num] = [100,200,300,400]): Num {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im pretty sure its supposed to be a: [Num], not a : [Num]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right now the tests are working in this way, maybe is just defining a array with numbers?

let sum = 0
loop n in a {
sum += n;
}
return sum;
}
let result = sum_array();
echo "1000"
7 changes: 7 additions & 0 deletions src/tests/validity/function_optional_argument_generic.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Output
// hello

fun echo_var(a = 100){
echo a
}
echo_var("hello")
9 changes: 9 additions & 0 deletions src/tests/validity/function_optional_argument_int.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Output
// 1010

fun addition(a: Num, b: Num = 100): Num {
return a + b
}

let result = addition(10, 1000)
echo result
7 changes: 7 additions & 0 deletions src/tests/validity/function_optional_argument_int_default.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Output
// 110
fun addition(a: Num, b: Num = 100): Num {
return a + b
}
let result = addition(10)
echo result