Skip to content

fn and lambda should support destructuring #4637

Description

@proppy

Describe the bug
Currently when passing an array of tuple to a map with lambda, we can't destructuring the element into a tuple.

To Reproduce

fn muladd(a: u8, b: u8, c: u8) -> u8 {
    let p = [(a, b, c)];
    map(p, |(a, b, c)| {
      a * b + c
    })[0]
}

0003: fn muladd(a: u8, b: u8, c: u8) -> u8 {
0004: let p = [(a, b, c)];
0005: map(p, |(a, b, c)| {

0006:       a * b + c
0007:     })
```

**Workaround**

Deconstruct the tuple explicitly within the lambda body:
```
fn muladd(a: u8, b: u8, c: u8) -> u8 {
    let p = [(a, b, c)];
    map(p, |t| {
      let (a, b, c) = t;
      a * b + c
    })[0]
}
```

**Expected behavior**
Tuple can be deconstructed within lambda parameter declaration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working or is incorrectdslxDSLX (domain specific language) implementation / front-end

    Type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions