aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorBradley Lewis <22850972+BradLewis@users.noreply.github.com>2025-09-10 21:07:49 -0400
committerGitHub <noreply@github.com>2025-09-10 21:07:49 -0400
commit7b5eac698391e9d0b2d6fdac4ce4a857f92c33f2 (patch)
treee54e75ab31e080349a203b1c440e3b158b72e757 /src/server
parent412da606f42f29a6f03392ff385bea6a3af60bb2 (diff)
parent88a9d4c081b9e04c33dcfd4d694cd4c780951f5b (diff)
Merge pull request #994 from BradLewis/chore/resolve-assign-comp-lits
Improvements to resolving assignment comp lits
Diffstat (limited to 'src/server')
-rw-r--r--src/server/analysis.odin33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index d5ba9d1..4f70fbd 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1995,6 +1995,39 @@ internal_resolve_comp_literal :: proc(
position_context.function.type.results.list[return_index].type,
) or_return
}
+ } else if position_context.assign != nil {
+ if len(position_context.assign.lhs) > 0 {
+ if position_in_exprs(position_context.assign.lhs, position_context.position) {
+ for n in position_context.assign.lhs {
+ if position_in_node(n, position_context.position) {
+ // check if we're a comp literal of a map key
+ if index_expr, ok := n.derived.(^ast.Index_Expr); ok {
+ if s, ok := resolve_proc(ast_context, index_expr.expr); ok {
+ if value, ok := s.value.(SymbolMapValue); ok {
+ symbol = resolve_proc(ast_context, value.key) or_return
+ }
+ }
+ } else {
+ symbol = resolve_proc(ast_context, n) or_return
+ }
+ break
+ }
+ }
+ } else {
+ index := 0
+ for value, i in position_context.assign.rhs {
+ if position_in_node(value, position_context.position) {
+ index = i
+ break
+ }
+ }
+ // Just to be safe
+ if index >= len(position_context.assign.lhs) {
+ index = 0
+ }
+ symbol = resolve_proc(ast_context, position_context.assign.lhs[index]) or_return
+ }
+ }
} else if position_context.value_decl != nil && position_context.value_decl.type != nil {
symbol = resolve_proc(ast_context, position_context.value_decl.type) or_return
}