mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
parent
f17e0fd52b
commit
e15d8fcf49
2 changed files with 24 additions and 4 deletions
|
@ -221,11 +221,14 @@ fn (mut c Checker) match_expr(mut node ast.MatchExpr) ast.Type {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !node.is_comptime || (node.is_comptime && comptime_match_branch_result) {
|
||||
if node.is_expr {
|
||||
c.stmts_ending_with_expression(mut branch.stmts, c.expected_or_type)
|
||||
} else {
|
||||
c.stmts(mut branch.stmts)
|
||||
}
|
||||
}
|
||||
c.smartcast_mut_pos = token.Pos{}
|
||||
c.smartcast_cond_pos = token.Pos{}
|
||||
if node.is_expr {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
module main
|
||||
|
||||
fn func[T]() bool {
|
||||
$match T {
|
||||
u8, u16 {
|
||||
return true
|
||||
}
|
||||
$else {
|
||||
// return false
|
||||
$compile_error('fail')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn test_comptime_match_eval_only_true_branch() {
|
||||
assert func[u8]()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue