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

Presence of type alias causes ambiguity in generated code #1493

Closed
bbannier opened this issue Aug 7, 2023 · 1 comment · Fixed by #1702
Closed

Presence of type alias causes ambiguity in generated code #1493

bbannier opened this issue Aug 7, 2023 · 1 comment · Fixed by #1702
Assignees
Labels
Bug Something isn't working Compiler

Comments

@bbannier
Copy link
Member

bbannier commented Aug 7, 2023

The mere presence of a type alias can lead to ambiguities in generated code which cause compilation to fail, e.g.,

module foo;

public type A = unit {
    : uint8;
};

public type B = A;  # PRESENCE OF THIS LINE TRIGGERS THE ERROR.
$ spicyc -dj foo.spicy
[error] foo.spicy:3:17-5:2: ID 'foo::A::parse1' is ambiguous
[error] foo.spicy:3:17-5:2: ID 'foo::A::parse2' is ambiguous
[error] foo.spicy:3:17-5:2: ID 'foo::A::parse3' is ambiguous
[error] foo.spicy:3:17-5:2: ID 'spicy_rt::waitForInput' is ambiguous
[error] foo.spicy:3:17-5:2: unknown ID 'self'
[error] spicyc: aborting after errors

The only workaround for now seems to be to not use a type alias in case it causes such errors.

@bbannier bbannier added Bug Something isn't working Compiler labels Aug 7, 2023
@bbannier
Copy link
Member Author

This error occurs regardless of whether the type A or the alias B are public or not.

@rsmmr rsmmr self-assigned this Mar 26, 2024
rsmmr added a commit that referenced this issue Mar 27, 2024
An alias like `public type Unit1 = Unit2` used to lead to C++-side
compiler errors, which this fixes. We also fully support this now by
making both `Unit1` and `Unit2` available for parsing to host
applications. Internally, the `Unit1` parser is just a small facade
pointing to the parsing functions for `Unit2`.

Closes #1493.
rsmmr added a commit that referenced this issue Apr 3, 2024
An alias like `public type Unit1 = Unit2` used to lead to C++-side
compiler errors, which this fixes. We also fully support this now by
making both `Unit1` and `Unit2` available for parsing to host
applications. Internally, the `Unit1` parser is just a small facade
pointing to the parsing functions for `Unit2`.

Closes #1493.
rsmmr added a commit that referenced this issue Apr 3, 2024
* origin/topic/robin/gh-1493-type-alias:
  Support/fix public type aliases to units.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants