diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-07-11 19:22:01 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-07-11 19:22:01 +0200 |
| commit | 9fccfd8ddc42de2275dad94f357eb3828fd3eeed (patch) | |
| tree | ff8341bb3cb795647cf70e6abb7d6a94f693a686 | |
| parent | 9192498f8f6c463015a4f8ce1904d28aa862133f (diff) | |
Add `for in string` support with runes.
| -rw-r--r-- | src/server/analysis.odin | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index dd7b3b0..132a054 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -2630,6 +2630,17 @@ make_int_ast :: proc( return ident } +make_rune_ast :: proc( + ast_context: ^AstContext, + pos: tokenizer.Pos, + end: tokenizer.Pos, +) -> ^ast.Ident { + ident := new_type(ast.Ident, pos, end, ast_context.allocator) + ident.name = "rune" + return ident +} + + make_ident_ast :: proc( ast_context: ^AstContext, pos: tokenizer.Pos, @@ -3541,6 +3552,24 @@ get_locals_for_range_stmt :: proc( if symbol, ok := resolve_type_expression(ast_context, stmt.expr); ok { #partial switch v in symbol.value { + case SymbolBasicValue: + if ident, ok := unwrap_ident(stmt.vals[0]); ok { + if v.ident.name == "string" { + store_local( + ast_context, + ident, + make_rune_ast(ast_context, ident.pos, ident.end), + ident.pos.offset, + ident.name, + ast_context.local_id, + ast_context.non_mutable_only, + false, + true, + symbol.pkg, + false, + ) + } + } case SymbolMapValue: if len(stmt.vals) >= 1 { if ident, ok := unwrap_ident(stmt.vals[0]); ok { |