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.06k stars 198 forks source link

Cannot identify variadic functions with `@type` reflection #7182

Open Chriscbr opened 1 month ago

Chriscbr commented 1 month ago

I tried this:

class Foo {
  pub bar(...xs: Array<num>): num {
    let var total = 0;
    for x in xs {
      total += x;
    }
    return total;
  }
}

let t = @type(Foo);
let cls = t.asClass()!;
log(cls.methods["bar"].child.toString());

This happened:

It prints out

preflight (Array): num

I expected this:

It should print out something like

preflight (...Array<num>): num

I also expected to have some way to see if the function is variadic or not:

assert(cls.methods["bar"].child.asFunction()!.isVariadic == true);

Is there a workaround?

No response

Anything else?

No response

Wing Version

0.85.13

Node.js Version

No response

Platform(s)

No response

Community Notes