v2 / vlib / v / tests / panic_on_match_branch_test.v
32 lines · 26 sloc · 379 bytes · 8e35f4d9848f7ad35d857a187dddbfd2eca5e19d
Raw
1module main
2
3pub struct Operand {
4pub:
5 typ OperandType = .reg_state
6}
7
8pub enum OperandType {
9 reg_self
10 reg_state
11}
12
13struct Value {
14}
15
16fn set_value(operand Operand, val2 &Value) {
17 val1 := match operand.typ {
18 .reg_state {
19 val2
20 }
21 .reg_self {
22 panic('ERR')
23 }
24 }
25
26 assert val1.str() == val2.str()
27}
28
29fn test_main() {
30 mut val := Value{}
31 set_value(Operand{}, &val)
32}
33