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

Emit a warning when matching a signal with an enum decoder with enum values of wrong type #384

Open
Ravenslofty opened this issue May 11, 2020 · 2 comments

Comments

@Ravenslofty
Copy link
Contributor

If you have x = Signal(decoder=Foo) and try to do x.match(Bar.QUUX) or m.Switch(x)/m.Case(Bar.QUUX), there should be an exception (TypeError?) thrown to catch any potential bugs where an enum of the wrong type is being used.

@whitequark
Copy link
Member

We can do this on a best-effort basis with a lint (warning by default diagnostic), but Amaranth is an untyped language (in that all values belong to the same type and are mutually interoperable regardless of how they're constructed) and it is not feasible to add a type system to it even if it was desired.

@whitequark whitequark closed this as not planned Won't fix, can't repro, duplicate, stale Jan 31, 2023
@whitequark whitequark reopened this Jan 31, 2023
@whitequark whitequark changed the title Catch matching on an enum of the wrong type Emit a warning when matching a signal with an enum decoder with enum values of wrong type Jan 31, 2023
@whitequark
Copy link
Member

This doesn't change the language and so doesn't need an RFC, someone can just implement it. @Ravenslofty?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants