xls
xls copied to clipboard
`XlsTypeError` in `config()` is missing information about the channel direction
Describe the bug
Currently, the XlsTypeError
for mismatched values in config()
does not provide any information about the channel's direction. This may be misleading especially when the same type of value is used in channels with different directions and causes the error. In that case, the Mismatched elements within the type
section is empty and the Overall type mismatch
shows the same values on both sides of the error.
To Reproduce
To reproduce the problem, one can use the following DSLX code:
proc Passthrough {
data_r: chan<u32> in;
data_s: chan<u32> out;
init {}
config (
data_r: chan<u32> in,
data_s: chan<u32> out
) {
(data_s, data_r) // here is the problem
}
next(tok: token, state: ()) {
let (tok, data) = recv(tok, data_r);
send(tok, data_s, data);
}
}
#[test_proc]
proc PassthroughTest {
terminator: chan<bool> out;
data_r: chan<u32> in;
data_s: chan<u32> out;
init {}
config (terminator: chan<bool> out) {
let (data_s, data_r) = chan<u32>;
spawn Passthrough(data_r, data_s);
(terminator, data_r, data_s)
}
next(tok: token, state: ()) {
let data_to_send = u32:123;
let tok = send(tok, data_s, data_to_send);
let (tok, received_data) = recv(tok, data_r);
assert_eq(data_to_send, received_data);
send(tok, terminator, true);
}
}
Here is the returned error:
0007: data_r: chan<u32> in,
0008: data_s: chan<u32> out
0009: ) {
______^
0010: | (data_s, data_r)
0011: | }
|_____^ XlsTypeError: Return type of function body for 'Passthrough.config' did not match the annotated return type.
Mismatched elements within type:
Overall type mismatch:
(chan(uN[32])chan(uN[32]))
vs (chan(uN[32])chan(uN[32]))
0012: next(tok: token, state: ()) {
0013: let (tok, data) = recv(tok, data_r);
Error parsing and type checking DSLX source file: xls/examples/passthrough.x
Expected behavior
The XlsTypeError
should include information about the channel types. The difference between channels with incorrect directions should be visible.
Additional context
- https://github.com/google/xls/issues/1379