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 use unit parameters to specify a literal to parse #1859

Closed
bbannier opened this issue Sep 6, 2024 · 1 comment · Fixed by #1912
Closed

Cannot use unit parameters to specify a literal to parse #1859

bbannier opened this issue Sep 6, 2024 · 1 comment · Fixed by #1912

Comments

@bbannier
Copy link
Member

bbannier commented Sep 6, 2024

When parsing a field one can use e.g., const values to specify literals to expect, but using unit parameters in the same place does not resolve, e.g.,

module foo;

type X = unit {
    : Y(0);
};

type Y = unit(expected: uint8) {
    : expected;
};
$ spicyc -dj foo.spicy
[error] foo.spicy:8:5-8:15: unknown ID 'expected'
[error] spicyc: aborting after errors
@rsmmr
Copy link
Member

rsmmr commented Sep 6, 2024

The error message isn't great but it's correct to reject this: these constants/literals must be know at compile time, so parameters can't be supported.

@rsmmr rsmmr added Diagnostics and removed Parsing labels Sep 6, 2024
@rsmmr rsmmr closed this as completed in 6e71326 Nov 7, 2024
rsmmr added a commit that referenced this issue Nov 7, 2024
…-literal'

* origin/topic/robin/gh-1859-no-params-as-literal:
  Improve error message when a unit parameter is used as a field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants