-
Notifications
You must be signed in to change notification settings - Fork 96
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
feat(test): for variables, #433 #553
Conversation
@Mte90 please add all shorthand operators like |
So like |
Yep, and do all that again for variables passed by reference:
|
Added :-) |
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mte90 the ref
keyword is used to access variables by reference through function arguments. I feel like you misunderstood the functionality it provides.
If we use ref
we can mutate certain value from the external environment. Here's an example of a function using reference and one that is not using references:
Reference
fun foo(ref arg) {
arg = "foo"
}
let my_var = "test"
foo(my_var)
echo my_var // Outputs: "foo"
No reference
fun foo(arg) {
arg = "foo"
}
let my_var = "test"
foo(my_var)
echo my_var // Outputs: "test"
Co-authored-by: Phoenix Himself <pkaras.it@gmail.com>
Updated, about |
@Mte90 yes, it is. Here in the documentation: https://docs.amber-lang.com/basic_syntax/functions#variable-references-ref |
Implemented |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to that you should create a new test that is it's own separate file for checking non-ref shorthand operators:
let sum = 42
sum += 32
echo sum
let sub = 64
sub -= 48
echo sub
// ...
We already have tests for shortand operators like in your example: https://github.com/amber-lang/amber/blob/master/src/tests/validity/shorthand_sub.ab |
Yeah... it seems that we already have tests for shorthand operators and ref shorthand operators. |
As per #433
I am not sure if I added all of them, in the case of another scopethere is an error if the variable is not defined and it is part of the errors we are not checking right now (another ticket).