assemblyscript icon indicating copy to clipboard operation
assemblyscript copied to clipboard

No support for rest paramaters

Open rfl890 opened this issue 3 years ago • 0 comments

I have the following code:

export function add(...args: Uint32Array): i32 {
  return args.reduce((a, b) => a + b, 0)
}

I'm getting error "AS215: Optional parameter must have an initializer.":

image

When I try to add initializer:

export function add(...args = []: Uint32Array): i32 {
  return args.reduce((a, b) => a + b, 0)
}

Then I'm getting error "TS1048: A rest parameter cannot have an initializer":

image

Originally posted by @jerrygreen in https://github.com/AssemblyScript/assemblyscript/issues/377#issuecomment-810021811

rfl890 avatar May 12 '22 01:05 rfl890