aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-08-12 01:07:20 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-08-12 01:07:20 +0200
commit4ad8229d1b6901a2598a86f8969a2348e02b94be (patch)
treef0816c281d95781def190e10ad9d48325d73596c /src/server
parente0976cc195980ca18f209cef52e6b7efc6d436ff (diff)
Better support for string range loop
Diffstat (limited to 'src/server')
-rw-r--r--src/server/analysis.odin52
1 files changed, 37 insertions, 15 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 597e1fc..ee73f16 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -3050,22 +3050,44 @@ get_locals_for_range_stmt :: proc(
if symbol, ok := resolve_type_expression(ast_context, stmt.expr); ok {
#partial switch v in symbol.value {
+ case SymbolUntypedValue:
+ if len(stmt.vals) == 1 {
+ if ident, ok := unwrap_ident(stmt.vals[0]); ok {
+ if v.type == .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 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,
- )
+ if len(stmt.vals) == 1 {
+ 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: