cgen: fix match for alias (#21028)

This commit is contained in:
Swastik Baranwal 2024-03-15 12:11:09 +05:30 committed by GitHub
parent 49b7f9a94a
commit 6a42f79ddc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -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

View 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
}