winglang / wing

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

Property not found error #6245

Open Chriscbr opened 7 months ago

Chriscbr commented 7 months ago

I tried this:

class A {
  pub var x: num;
  new() {
    this.x = 5;
  }
}

let a = new A();

let foo = () => {
  return a;
};

a.x = 5; // OK
let y = foo().x; // error: Property not found
foo().x = 5; // error: Property not found

This happened:

The compiler raised several "Property not found" errors

I expected this:

No error

Is there a workaround?

Add an explicit return type annotation to foo:

let foo = (): A => {
  return a;
};

Anything else?

No response

Wing Version

0.70.6

Node.js Version

20.11.1

Platform(s)

MacOS

Community Notes

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!

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