2022-11-05 10:57:28 +01:00
|
|
|
# Tests var parameters. TODO: They don't actually exist yet, they're just checked statically
|
2022-06-19 14:44:14 +02:00
|
|
|
|
2022-08-17 17:31:15 +02:00
|
|
|
import std;
|
2022-06-19 14:44:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
operator `+=`(a: var int, b: int) {
|
|
|
|
a = a + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-15 19:07:06 +02:00
|
|
|
fn plusOne(x: var int): int {
|
2022-06-19 14:44:14 +02:00
|
|
|
x += 1;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var x = 5;
|
2022-08-15 19:07:06 +02:00
|
|
|
print(plusOne(x));
|
|
|
|
# plusOne(38); # If you uncomment this, the compiler errors out!
|