cgen: fix match for one branch (#9234)
							parent
							
								
									eefdad21c7
								
							
						
					
					
						commit
						8d84206a8c
					
				| 
						 | 
					@ -3810,7 +3810,7 @@ fn (mut g Gen) match_expr_classic(node ast.MatchExpr, is_expr bool, cond_var str
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		g.stmts_with_tmp_var(branch.stmts, tmp_var)
 | 
							g.stmts_with_tmp_var(branch.stmts, tmp_var)
 | 
				
			||||||
		if g.inside_ternary == 0 && node.branches.len > 1 {
 | 
							if g.inside_ternary == 0 && node.branches.len >= 1 {
 | 
				
			||||||
			g.write('}')
 | 
								g.write('}')
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,12 @@
 | 
				
			||||||
 | 
					enum Color {
 | 
				
			||||||
 | 
						red
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn test_match_one_branch() {
 | 
				
			||||||
 | 
						col := Color.red
 | 
				
			||||||
 | 
						match col {
 | 
				
			||||||
 | 
							.red {
 | 
				
			||||||
 | 
								assert true
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue