-
-
Notifications
You must be signed in to change notification settings - Fork 663
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
Fix / Enhancement for Omitted Object Literals #1229
Fix / Enhancement for Omitted Object Literals #1229
Conversation
Oops, seems like I am failing the self-compilation tests 🙃 @dcodeIO did you get things self compiling? Should I go back and fix these? Shouldn't be too hard, all I think I really need to do is get rid of the phat arraw function I added 😄 But how do I test the self compiler from my machine? 🤔 |
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.
Had an initial look and found a couple places that are fine in TS, but a bit tricky in the compiler's "portable AssemblyScript" codebase :)
Regarding self-compilation: Yes, this is indeed part of CI now. The relevant scripts are |
Isn't this relate to #1155 ? |
It's somewhat related conceptually, yeah. Let's say we call the (default) ctor on object creation, then the ctor may initialize some of these fields, so specifying these is not necessary even though the field is not nullable. However, we are not calling the ctor here even though we should. Suggesting to do the following to be safe for now: As soon as the class has a constructor, disallow creating it from an object literal. This should avoid any issues, and we can look into actually calling ctors in a later PR. |
It's unfortunate that we aren't like rust, and get to have traits where object literals might make sense. |
@dcodeIO Made all requested changes, and asbuild works on my machine 😄 👍 This is good to go! |
Nice work @torch2424 |
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.
Thanks! Got a few additional comments, with one RC issue not introduced by this PR, but seems good to fix as well.
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.
Great! Just a couple nits left, and a suggestion how to support omitting fields that are nullable anyway :)
@dcodeIO Made requested changes, tests still pass, asbuild still working 😄 👍 |
Thank you! :) |
Yayyyy! 😄 @dcodeIO Thank you very much for the review. Literally tweeting this out now 😂 |
closes #1226
This fixes the bug where omitted Object literals would just give random memory from the runtime. By introducing an error for class fields that cannot be omitted.
This Enhances Object literals, by allowing the basic AS Types. To be omitted, with default values of zero 😄
TODO: Either we add support for nullable types to default to null and/or add support for making a new instance of a class if the constructor has no parameters in this same PR. Or we can do that work in a seperate PR 😄
cc @dcodeIO @jtenner
P.S. Yay! My first real AS Compiler PR 😄 🎉
Screenshots