Skip to content

dslx parse error on expressions with inline for #3967

@proppy

Description

@proppy

Describe the bug

0003: fn foo(arg: bits[9]) -> bool {
0004:     let p = arg[8 +: u1];
0005:     p ^ for (i, acc) in u32:0..u32:8 {
~~~~~~~~~~~~~~^-^ ParseError: Expected start of an expression; got: keyword:for
0006:       arg[i+:u1] ^ acc
0007:     }(u1:1)

To Reproduce

fn foo(arg: bits[9]) -> bool {
    let p = arg[8 +: u1];
    p ^ for (i, acc) in u32:0..u32:8 {
      arg[i+:u1] ^ acc
    }(u1:1)
}

Expected behavior

expressions with an inline for are valid.

Workaround

Use a separate let binding:

fn foo(arg: bits[9]) -> bool {
    let p = arg[8 +: u1];
    let f = for (i, acc) in u32:0..u32:8 {
      arg[i+:u1] ^ acc
    }(u1:1);
    p ^ f
}

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