aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-12 20:07:53 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-07-13 06:50:19 -0400
commit3dbcf0183f6523d89c85bbf3324bc389ca7707a5 (patch)
tree555a2322de7fb017baf78d8c850fe568fdabaceb
parentbbb3bc903e241e63e36552d6707b41eab926b419 (diff)
Fix issue resolving comparison binary expr
-rw-r--r--src/server/analysis.odin10
-rw-r--r--tests/hover_test.odin23
2 files changed, 33 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index e1ebfd6..c4de6dd 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1467,6 +1467,8 @@ internal_resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide
return_symbol, ok = resolve_basic_lit(ast_context, v^)
return_symbol.name = node.name
return_symbol.type = local.variable ? .Variable : .Constant
+ case ^ast.Binary_Expr:
+ return_symbol, ok = resolve_binary_expression(ast_context, v)
case:
return_symbol, ok = internal_resolve_type_expression(ast_context, local.rhs)
}
@@ -2415,6 +2417,14 @@ resolve_binary_expression :: proc(ast_context: ^AstContext, binary: ^ast.Binary_
symbol_a, symbol_b: Symbol
ok_a, ok_b: bool
+ #partial switch binary.op.kind {
+ case .Cmp_Eq, .Gt, .Gt_Eq, .Lt, .Lt_Eq:
+ symbol_a.value = SymbolUntypedValue {
+ type = .Bool,
+ }
+ return symbol_a, true
+ }
+
if expr, ok := binary.left.derived.(^ast.Binary_Expr); ok {
symbol_a, ok_a = resolve_binary_expression(ast_context, expr)
} else {
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index af9990e..a69b494 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -2559,6 +2559,29 @@ ast_hover_struct_field_should_show_docs_and_comments_matrix :: proc(t: ^testing.
}
test.expect_hover( t, &source, "Foo.bar: matrix[4,5]int // bar comment\n bar docs")
}
+
+@(test)
+ast_hover_variable_from_comparison :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+
+ Foo :: enum {
+ A,
+ B,
+ }
+
+ Bar :: struct {
+ foo: Foo,
+ }
+
+ main :: proc() {
+ bar: Bar
+ b{*}azz := bar.bar == .A
+ }
+ `,
+ }
+ test.expect_hover( t, &source, "test.bazz: bool")
+}
/*
Waiting for odin fix