mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
This commit is contained in:
parent
02ca30acf0
commit
92f436db12
@ -127,7 +127,7 @@ fn (mut c Checker) match_expr(mut node ast.MatchExpr) ast.Type {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if stmt.typ != ast.error_type {
|
if stmt.typ != ast.error_type && !is_noreturn_callexpr(stmt.expr) {
|
||||||
ret_sym := c.table.sym(ret_type)
|
ret_sym := c.table.sym(ret_type)
|
||||||
stmt_sym := c.table.sym(stmt.typ)
|
stmt_sym := c.table.sym(stmt.typ)
|
||||||
if ret_sym.kind !in [.sum_type, .interface]
|
if ret_sym.kind !in [.sum_type, .interface]
|
||||||
|
31
vlib/v/tests/panic_on_match_branch_test.v
Normal file
31
vlib/v/tests/panic_on_match_branch_test.v
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
module main
|
||||||
|
|
||||||
|
pub struct Operand {
|
||||||
|
pub:
|
||||||
|
typ OperandType = .reg_state
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum OperandType {
|
||||||
|
reg_self
|
||||||
|
reg_state
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Value {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_value(operand Operand, val2 &Value) {
|
||||||
|
val1 := match operand.typ {
|
||||||
|
.reg_state {
|
||||||
|
val2
|
||||||
|
}
|
||||||
|
.reg_self {
|
||||||
|
panic('ERR')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert val1.str() == val2.str()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_main() {
|
||||||
|
mut val := Value{}
|
||||||
|
set_value(Operand{}, &val)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user