GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||
GeezerVison is showing github.com — Implement calls to 'super()' by dcodeIO · Pull Request #445 · AssemblyScript/assemblyscript Conversation
|
|
Hmm, I'm not sure about first statement call rule. It make sense only if constructor(a: i32) { var arg = a + 1; super(arg); } |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Yeah, there are the ALLOCATES and CONDITIONALLY_ALLOCATES flags in flows for that. Will probably need a CALLS_SUPER one as well then to do it this way. TS also has Maybe we could use "'super' must be called before accessing 'this' in the constructor of a derived class.": { "category": "Error", "code": 17009 }, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Yeah |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Seems constructor(a: i32) { var arg = a + 1; super(arg); } is rejected by TS, but now legalized in AS with the flow changes above. Still needs a check when doing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hmm, really? That's interesting... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yeah, but PR for fixing this in TS already exists: microsoft/TypeScript#29374 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Yeah, I remember that this limitation annoyed me in the past. Especially given the dynamic nature of JavaScript this seems like an arbitrary restriction (not directly related to AS, where such a restriction might actually make sense). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
As I know this legal in any OOP typed languages may be except C#. It seems typescript just missing this ability. But this should be fix soon |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
One thing that's still particularly off is that derived classes currently inherit their super class's fields, and thus initialize super fields in each derived constructor, which is odd. Instead, each constructor should initialize its own class's fields right after bubbling up the entire prototype chain, calling all the overloaded constructors sequentially. One reason why this doesn't yet work is that classes that don't have an explicit constructor also don't have a wasm function for it (their field initialization is instead inlined), which we should change by generating actual constructor functions for them that we can call. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Makes sense. But it look like not simple. May be better leave this for other PR? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Sure, makes sense to leave that for a separate PR. One example what's not possible until then: class A { a: i32 = 1; constructor() { assert(this.a == 1); // == 0, is uninitialized, and remains so } } class B extends A { a: i32 = 3; constructor() { super(); } } new B(); This is currently prevented by rejecting duplicate field names. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Similarly: Not directly related to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Merging, continuing in a separate PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
New to the assemblyscript project, and coming here because I hit this bug: #245 Does this mean that OO stuff in general isn't supported by assembly script at the moment? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@robrohan Basic OO supports except virtual methods. Issue which you mentioned is not yet fixed. If you add some params to basic constructor it would work |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.