File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,10 +221,13 @@ fn (mut c Checker) match_expr(mut node ast.MatchExpr) ast.Type {
221221 }
222222 }
223223 }
224- if node.is_expr {
225- c.stmts_ending_with_expression (mut branch.stmts, c.expected_or_type)
226- } else {
227- c.stmts (mut branch.stmts)
224+
225+ if ! node.is_comptime || (node.is_comptime && comptime_match_branch_result) {
226+ if node.is_expr {
227+ c.stmts_ending_with_expression (mut branch.stmts, c.expected_or_type)
228+ } else {
229+ c.stmts (mut branch.stmts)
230+ }
228231 }
229232 c.smartcast_mut_pos = token.Pos{}
230233 c.smartcast_cond_pos = token.Pos{}
Original file line number Diff line number Diff line change 1+ module main
2+
3+ fn func [T]() bool {
4+ $match T {
5+ u8 , u16 {
6+ return true
7+ }
8+ $else {
9+ // return false
10+ $compile_error ('fail' )
11+ }
12+ }
13+ }
14+
15+ fn test_comptime_match_eval_only_true_branch () {
16+ assert func[u8 ]()
17+ }
You can’t perform that action at this time.
0 commit comments