diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-19 12:19:01 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-08-19 12:38:25 -0400 |
| commit | 558f690a8d962b658986bc28fa1e5603098674c1 (patch) | |
| tree | eaa3b34ecdb5af1ccaa0f347b8482c4bf0c8f681 /src/server/analysis.odin | |
| parent | 9ffbad23c023a84f568d6079e1181442f5e70500 (diff) | |
Correctly resolve string indexing
Diffstat (limited to 'src/server/analysis.odin')
| -rw-r--r-- | src/server/analysis.odin | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index c1d0016..7c51b69 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1238,6 +1238,24 @@ resolve_index_expr :: proc(ast_context: ^AstContext, v: ^ast.Index_Expr) -> (Sym ok = internal_resolve_type_expression(ast_context, v2.value, &symbol) case SymbolMultiPointerValue: ok = internal_resolve_type_expression(ast_context, v2.expr, &symbol) + case SymbolBasicValue: + if v2.ident.name == "string" { + v2.ident.name = "u8" + indexed.name = "u8" + return indexed, true + } + return {}, false + case SymbolUntypedValue: + if v2.type == .String { + value := SymbolBasicValue{ + ident = ast.new(ast.Ident, v2.tok.pos, v2.tok.pos), + } + value.ident.name = "u8" + indexed.name = "u8" + indexed.value = value + return indexed, true + } + return {}, false } @@ -1887,6 +1905,11 @@ resolve_slice_expression :: proc(ast_context: ^AstContext, slice_expr: ^ast.Slic return symbol, true } return {}, false + case SymbolBasicValue: + if v.ident.name == "string" { + return symbol, true + } + return {}, false case: return {}, false } |