mirror of
https://github.com/vlang/v.git
synced 2025-09-15 10:27:19 -04:00
cgen: fix match for alias (#21028)
This commit is contained in:
parent
49b7f9a94a
commit
6a42f79ddc
@ -417,7 +417,7 @@ fn (mut g Gen) should_check_low_bound_in_range_expr(expr ast.RangeExpr, node_con
|
||||
|
||||
fn (mut g Gen) match_expr_classic(node ast.MatchExpr, is_expr bool, cond_var string, tmp_var string) {
|
||||
node_cond_type_unsigned := node.cond_type in [ast.u16_type, ast.u32_type, ast.u64_type]
|
||||
type_sym := g.table.sym(node.cond_type)
|
||||
type_sym := g.table.final_sym(node.cond_type)
|
||||
use_ternary := is_expr && tmp_var.len == 0
|
||||
for j, branch in node.branches {
|
||||
is_last := j == node.branches.len - 1
|
||||
|
15
vlib/v/tests/alias_string_match_test.v
Normal file
15
vlib/v/tests/alias_string_match_test.v
Normal file
@ -0,0 +1,15 @@
|
||||
type ReleaseTarget = string
|
||||
|
||||
const production = ReleaseTarget('production')
|
||||
const testing = ReleaseTarget('testing')
|
||||
|
||||
fn test_alias_string_match() {
|
||||
target := match ReleaseTarget('testing') {
|
||||
production { production }
|
||||
testing { testing }
|
||||
else { panic(error('Invalid target')) }
|
||||
}
|
||||
|
||||
assert target == ReleaseTarget('testing')
|
||||
assert target == testing
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user