-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Description
When pattern matching an enum variant with data, the bound variable is not accessible inside the case block.
Steps to Reproduce
struct Node {
value: int,
next: option<Node>
}
fn main() {
var n2: Node = Node { value: 2, next: none };
var n1: Node = Node { value: 1, next: some(n2) };
switch (n1.next) {
case Some(n): {
println("{}", n.value); // ERROR: undefined variable 'n'
}
default: {
println("none");
}
}
}
Expected: Prints 2
Actual: undefined variable 'n' at ...
Notes
The binding n from case Some(n) is recognized during parsing but not properly defined as a variable in scope during type checking or codegen, preventing field access on it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels