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.76k stars 187 forks source link

Implicit empty keyword struct doesn't work for static methods #6559

Closed eladb closed 3 weeks ago

eladb commented 1 month ago

I tried this:

struct Query {
  bar: str?;
  zoo: str?;
}

class Foo {
  pub static bar(q: Query) {
    if let bar = q.bar {
      log(bar);
    }

    if let zoo = q.zoo {
      log(zoo);
    }
  }
}

Foo.bar();

This happened:

A preflight error:

Failed to compile.

Error: Cannot read properties of undefined (reading 'bar')

I expected this:

No response

Is there a workaround?

Pass an empty object:

Foo.bar({});

Anything else?

No response

Wing Version

No response

Node.js Version

No response

Platform(s)

No response

Community Notes

monadabot commented 3 weeks ago

Congrats! :rocket: This was released in Wing 0.74.36.