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.79k stars 189 forks source link

No type checking when overriding a method/field #6158

Open yoav-steinberg opened 3 months ago

yoav-steinberg commented 3 months ago

I tried this:

class A {
  f: num;
  pub method():num { return 1; }
  new() { this.f = 1; }
}

class B extends A {
  f: str; // Expected an error here because we're overriding `f` with a different type (I guess we should enforce no overriding of fields)
  pub method():str { return "a"; } // Expected an error here because we're overriding `method` with a different type
  new() { this.f = "b"; }
}

This happened:

It compiles

I expected this:

Compilation error during type checking phase

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

github-actions[bot] commented 1 week 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!