aboutsummaryrefslogtreecommitdiff
path: root/src/server/action.odin
diff options
context:
space:
mode:
authorNathaniel Saxe <NathanielSaxophone@gmail.com>2026-01-30 00:39:02 -0500
committerNathaniel Saxe <NathanielSaxophone@gmail.com>2026-01-30 00:39:02 -0500
commitdc0196b01092768689e2bc943a011440ae99119a (patch)
tree0c53214e0319b0f08a7d9344937aaf1de22f1879 /src/server/action.odin
parenteea11e9d1e3035b89351cd888b35b920a40de81b (diff)
more or less handle union types - TODO in appropriate places on why not completely handled
Diffstat (limited to 'src/server/action.odin')
-rw-r--r--src/server/action.odin14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/server/action.odin b/src/server/action.odin
index 2099950..d5b4a90 100644
--- a/src/server/action.odin
+++ b/src/server/action.odin
@@ -239,8 +239,10 @@ get_switch_cases_info :: proc(
break
}
} else {
- if ident, ok := name.derived.(^ast.Ident); ok {
- case_name = ident.name
+ if ty, ok := resolve_type_expression(ast_context, name); ok {
+ //TODO: this is wrong for anonymous enums and structs, where the name field is "enum" or "struct" respectively but we want to use the full signature
+ //we also can't use the signature all the time because type aliases need to use specifically the alias name here and not the signature
+ case_name = ty.name != "" ? ty.name : get_signature(ast_context, ty)
break
}
}
@@ -260,7 +262,13 @@ get_switch_cases_info :: proc(
if !unwrap_ok {return nil, nil, false, false}
case_names := make([]string, len(union_value.types), context.temp_allocator)
for t, i in union_value.types {
- case_names[i] = t.derived.(^ast.Ident).name
+ if ty, ok := resolve_type_expression(ast_context, t); ok {
+ //TODO: this is wrong for anonymous enums and structs, where the name field is "enum" or "struct" respectively but we want to use the full signature
+ //we also can't use the signature all the time because type aliases need to use specifically the alias name here and not the signature
+ case_names[i] = ty.name != "" ? ty.name : get_signature(ast_context, ty)
+ } else {
+ case_names[i] = "invalid type expression"
+ }
}
return existing_cases, case_names, false, true
}