I get the following error when I use a fail! in a proc's next function -
F0407 10:53:32.670126 6863 opt_main.cc:120] Check failed: ::absl::OkStatus() == (xls::tools::RealMain(positional_arguments[0])) (OK vs. INTERNAL: Side-effecting token-typed nodes must be connected to the sink token value via a path of tokens: assert.47.; [after 'Inlines invocations' pass, dynamic pass #118]
=== Source Location Trace: ===
third_party/xls/passes/pass_base.h:376
)
To reproduce the error -
fn out_fn(x: u32, state: u32) -> u32 {
match x {
u32:0 => fail!("bad_x", state),
_ => x + state
}
}
proc Fmac {
input_a_consumer: chan<u32> in;
output_producer: chan<u32> out;
init { u32:0 }
config(input_a_consumer: chan<u32> in, output_producer: chan<u32> out) {
(input_a_consumer, output_producer)
}
next(tok: token, state: u32) {
let (tok, input_a) = recv(tok, input_a_consumer);
let result = out_fn(input_a, state);
let tok = send(tok, output_producer, result);
result
}
}
If I comment out the case with fail!, it compiles. Is there a correct way to use fail! in proc?