assemblyscript
assemblyscript copied to clipboard
[Feature] Supports (parse & compile) function expressions as instance and class members
class Foo {
static a = (): i32 => { // ERROR TS1110: Type expected.
return 1;
}
b = (): i32 => { // ERROR TS1110: Type expected.
return 2;
}
}
Instance method automatically lower it to simple FunctionDeclaration
due to class members are immutable in AS while class (static) function members can be reassigned so premature optimization is not possible.
Same for interfaces:
interface IFoo {
a: () => i32
}
due to class members are immutable in AS
Static class members can in fact be re-assigned, like Foo.a = ...
. These become globals underneath. We would need to know that re-assignments never happen to make these fully static.
Hmm, perhaps we can support reassignment for static function members. Will add note