From 0b7271488d9f339f0be3a0f7ccb81dd2d5dfb7df Mon Sep 17 00:00:00 2001 From: Brad Lewis <22850972+BradLewis@users.noreply.github.com> Date: Thu, 6 Nov 2025 05:15:13 -0500 Subject: Resolve implicit selector switch statements before index expressions --- src/server/analysis.odin | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/server/analysis.odin') diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 1b14497..4a1980c 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -2367,29 +2367,6 @@ resolve_implicit_selector :: proc( } } - if position_context.index != nil { - symbol: Symbol - ok := false - if position_context.previous_index != nil { - symbol, ok = resolve_type_expression(ast_context, position_context.previous_index) - if !ok { - return {}, false - } - } else { - symbol, ok = resolve_type_expression(ast_context, position_context.index.expr) - if !ok { - return {}, false - } - } - - #partial switch value in symbol.value { - case SymbolFixedArrayValue: - return resolve_type_expression(ast_context, value.len) - case SymbolMapValue: - return resolve_type_expression(ast_context, value.key) - } - } - if position_context.comp_lit != nil && position_context.parent_comp_lit != nil { if symbol, ok := resolve_comp_literal(ast_context, position_context); ok { return resolve_implicit_selector_comp_literal(ast_context, position_context, symbol) @@ -2430,6 +2407,29 @@ resolve_implicit_selector :: proc( } } + if position_context.index != nil { + symbol: Symbol + ok := false + if position_context.previous_index != nil { + symbol, ok = resolve_type_expression(ast_context, position_context.previous_index) + if !ok { + return {}, false + } + } else { + symbol, ok = resolve_type_expression(ast_context, position_context.index.expr) + if !ok { + return {}, false + } + } + + #partial switch value in symbol.value { + case SymbolFixedArrayValue: + return resolve_type_expression(ast_context, value.len) + case SymbolMapValue: + return resolve_type_expression(ast_context, value.key) + } + } + if position_context.returns != nil && position_context.function != nil { return_index: int -- cgit v1.2.3