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

Cannot forward const data from filter #1659

Closed
bbannier opened this issue Jan 24, 2024 · 0 comments · Fixed by #1671
Closed

Cannot forward const data from filter #1659

bbannier opened this issue Jan 24, 2024 · 0 comments · Fixed by #1671
Assignees
Labels
Bug Something isn't working

Comments

@bbannier
Copy link
Member

Currently a filter's forward method claims to require inout bytes, but we always only copy the data. This makes it impossible to forward const data, e.g.,

module foo;

const C = b"";

type F = unit {
    %filter;
    : bytes &eod &convert=$$.split(b" ") {
        for (x in $$) {
            self.forward(x); # FAIL: `x` is `const`.
            self.forward(C); # FAIL: `C` is an actual `const`.
        }
    }
};

public type X = unit {
    on %init {
        self.connect_filter(new F);
    }
};
$ spicyc -j foo.spicy
[error] foo.spicy:9:13-9:27: unsupported operator: <foo::F>.forward(<const bytes>)
[error] foo.spicy:10:13-10:27: unsupported operator: <foo::F>.forward(<const bytes>)
[error] spicyc: aborting after errors

We should drop the inout requirement from forward.

As a workaround one currently could create a new local variable, e.g.,

            local y = C;
            self.forward(y); # WORKS.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant