winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
4.97k stars 196 forks source link

Missing error when derived class does not call `super` in initializer #4277

Closed Chriscbr closed 3 months ago

Chriscbr commented 1 year ago

I tried this:

class Foo {
  new(name: str) {}
}

class Bar extends Foo {
  new() {}
}

This happened:

It compiles

I expected this:

A type checking error, saying that Bar's initializer needs a super call since it is a derived class

Is there a workaround?

No response

Component

Compiler

Wing Version

0.33.3

Node.js Version

18.14.1

Platform(s)

MacOS

Anything else?

No response

Community Notes

KrishnaSindhur commented 11 months ago

i can take look if its still open?

staycoolcall911 commented 11 months ago

Thanks @KrishnaSindhur, I assigned the issue to you. Please let us know if you have any questions or need pointers

github-actions[bot] commented 9 months ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 7 months ago

Hi,

This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

github-actions[bot] commented 4 months ago

Hi,

This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. Feel free to re-open this issue when there's an update or relevant information to be added. Thanks!

staycoolcall911 commented 3 months ago

This now correctly yields the desired error message (Wing V0.74.30):

Failed to compile.

error: Missing super() call as first statement of Bar's constructor
  --> wing/main.w:6:9
  |
6 |   new() {}
  |         ^^
staycoolcall911 commented 3 months ago

Fixed in #6351