From bb7e99dde0049e9e1ec3437f45a8b3ccfe98e959 Mon Sep 17 00:00:00 2001 From: Nathaniel Saxe Date: Sat, 31 Jan 2026 15:56:08 -0500 Subject: fix: reset ast context between resolve calls --- src/server/action.odin | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/server/action.odin b/src/server/action.odin index d5b4a90..58dc794 100644 --- a/src/server/action.odin +++ b/src/server/action.odin @@ -239,6 +239,7 @@ get_switch_cases_info :: proc( break } } else { + reset_ast_context(ast_context) 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 @@ -254,14 +255,23 @@ get_switch_cases_info :: proc( } if is_enum { enum_value, was_super_enum, unwrap_ok := unwrap_enum(ast_context, position_context.switch_stmt.cond) - if !unwrap_ok {return nil, nil, true, false} + if !unwrap_ok { + return nil, nil, true, false + } return existing_cases, enum_value.names, !was_super_enum, true } else { st := position_context.switch_type_stmt + if st == nil { + return nil, nil, false, false + } + reset_ast_context(ast_context) union_value, unwrap_ok := unwrap_union(ast_context, st.tag.derived.(^ast.Assign_Stmt).rhs[0]) - if !unwrap_ok {return nil, nil, false, false} + 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 { + reset_ast_context(ast_context) 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 -- cgit v1.2.3