Skip to content
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

super() call should not be required if there is no constructor #6498

Open
eladb opened this issue May 16, 2024 · 3 comments
Open

super() call should not be required if there is no constructor #6498

eladb opened this issue May 16, 2024 · 3 comments
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler 🙋‍♀️ help wanted Extra attention is needed 📐 language-design Language architecture

Comments

@eladb
Copy link
Contributor

eladb commented May 16, 2024

I tried this:

bring cloud;

class Foo extends cloud.Function {
  
}

This happened:

error: Missing super() call as first statement of Foo's constructor
  --> wing/main.w:3:7
  |
3 | class Foo extends cloud.Function {
  |       ^^^

I expected this:

No response

Is there a workaround?

No response

Anything else?

No response

Wing Version

No response

Node.js Version

No response

Platform(s)

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
@eladb eladb added the 🐛 bug Something isn't working label May 16, 2024
@yoav-steinberg
Copy link
Collaborator

yoav-steinberg commented May 16, 2024

just clarifying that the desired behavior is just to use the parent ctor if none is provided (and there are no new fields that need to be initialized).

@staycoolcall911 staycoolcall911 added 📐 language-design Language architecture needs-discussion Further discussion is needed prior to impl labels May 21, 2024
@Chriscbr
Copy link
Contributor

I think TypeScript does something similar. 👍 For anyone implementing the feature, something like this should work:

class Foo extends cloud.Function {}

but this should still emit an error (because the new field needs to be initialized):

class Foo extends cloud.Function {
  bar: str;
  // error: missing constructor ("bar" needs to be initialized)
}

(side note: if Wing had abstract classes there might be more edge cases, but I guess we aren't dealing with that quite yet :-))

@Chriscbr Chriscbr added 🙋‍♀️ help wanted Extra attention is needed and removed needs-discussion Further discussion is needed prior to impl labels May 21, 2024
@yoav-steinberg
Copy link
Collaborator

yoav-steinberg commented May 21, 2024

I think TypeScript does something similar.

It does, but I also verified that there are OO languages that don't, Java for example. I'm still for this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🛠️ compiler Compiler 🙋‍♀️ help wanted Extra attention is needed 📐 language-design Language architecture
Projects
Status: 🤝 Backlog - handoff to owners
Development

No branches or pull requests

4 participants