test250
auto test250 =
q{--- test250.vx
// @static variables inside functions and structs
u64 incAndReturn1() {
@static u64 var = 42;
++var;
return var;
}
// broadcasted variant
u64 incAndReturn2() {
@static:
u64 var1 = 10;
u64 var2 = 42;
++var1;
++var2;
return var1 + var2;
}
struct S {
@static u64 structVar = 50;
u64 incAndReturn1() {
++structVar;
return structVar;
}
u64 incAndReturn2() {
++this.structVar;
return this.structVar;
}
}
// @static struct member
u64 incAndReturn3() {
++S.structVar;
return S.structVar;
}
// through variable
u64 incAndReturn4() {
S s;
++s.structVar;
return s.structVar;
}
// through method of instance
u64 incAndReturn5() {
S s;
return s.incAndReturn1();
}
// through method of instance through this
u64 incAndReturn6() {
S s;
return s.incAndReturn2();
}
};
tests passing
functionsvariables