Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XlsTypeError in config() is missing information about the channel direction #1392

Open
rw1nkler opened this issue Apr 24, 2024 · 0 comments
Open
Labels
bug Something isn't working or is incorrect dslx DSLX (domain specific language) implementation / front-end

Comments

@rw1nkler
Copy link
Contributor

rw1nkler commented Apr 24, 2024

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

@rw1nkler rw1nkler changed the title XlsTypeError in config() is missing information about the channel direction XlsTypeError in config() is missing information about the channel direction Apr 24, 2024
copybara-service bot pushed a commit that referenced this issue May 24, 2024
This PR adds a simple proc that forwards the received information from an input channel to an output channel. We found this particular proc surprisingly useful when testing various tools within the toolchain or when reporting bugs.

We used it in:
* #1415
* #1410
* #1392
* #1057

COPYBARA_INTEGRATE_REVIEW=#1416 from antmicro:passthrough 907a62b
PiperOrigin-RevId: 636954688
@proppy proppy added bug Something isn't working or is incorrect dslx DSLX (domain specific language) implementation / front-end labels May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or is incorrect dslx DSLX (domain specific language) implementation / front-end
Projects
None yet
Development

No branches or pull requests

2 participants