Skip to content

Parsing breaks with non-trivial final expression in proc's config function #3746

@magancarz

Description

@magancarz

Describe the bug
Parsing breaks when the final expression in proc's config function is not a simple tuple, but its type is still a tuple.

To Reproduce
Issue can be reproduced by parsing this example:

const COND = true;
proc Proc {
  input: chan<()> in;
  output: chan<()> out;
  config() {
    const if COND {
      let (first_output, first_input) = chan<()>("first");
      (first_input, first_output)
    } else {
      let (second_output, second_input) = chan<()>("second");
      (second_input, second_output)
    }
  }
  init { () }
  next(state: ()) { () }
}

It fails with the following error:

INVALID_ARGUMENT: ParseError: foo.x:9:11-15:6 The final expression in a Proc config must be a tuple with one element for each Proc data member.

Expected behavior
Such expressions can be allowed to pass the parsing stage and generate an error during type checking when the type returned by the final expression is not a matching tuple.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions