-
Notifications
You must be signed in to change notification settings - Fork 97
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the Bug
(I'm using rinf cli v8.7.2)
When exporting a Rust enum as a signal, matching is a bit off inside Dart switch statements.
To Reproduce
- Create a RustSignal enum:
#[derive(Serialize, RustSignal)]
pub enum MyState {
A(String),
B(i64),
}
- Create a switch statement in Dart:
switch (myState.message) {
MyStateA(:final value) => handleA(value),
MyStateB(:final value) => handleB(value),
}
Expected Behavior
I'd expect it to compile, because all enum variants are handled, but the error is:
The type 'MyState' isn't exhaustively matched by the switch cases since it doesn't match the pattern 'MyState()'.
Try adding a wildcard pattern or cases that match 'MyState()'
Proposed Solution
Instead of generating an abstract class MyState
, a sealed class MyState
would fix the issue. I did the change manually in my code and did not notice any unwanted side effects.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working