aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBradley Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-26 20:12:08 -0400
committerGitHub <noreply@github.com>2025-08-26 20:12:08 -0400
commite211cdcdb8f6ab65fffb24552b89956c06f150cb (patch)
tree4b7324d0ead6ea2cf78171ac476d52e58ea48c40
parent6143ef543b432cd3b93d9f85b443f0ef16db5053 (diff)
parentf0ba60610758820cde9ef1c79d3defbaf9543d72 (diff)
Merge pull request #937 from BradLewis/feat/ternary-statements
Resolve ternary expressions
-rw-r--r--src/server/analysis.odin7
-rw-r--r--tests/hover_test.odin10
2 files changed, 16 insertions, 1 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 8d2b4f8..cde9c5d 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1115,7 +1115,12 @@ internal_resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Ex
}
out^ = make_symbol_poly_type_from_ast(ast_context, v.type)
return true
-
+ case ^ast.Ternary_If_Expr:
+ out^, ok = resolve_type_expression(ast_context, v.x)
+ return ok
+ case ^ast.Ternary_When_Expr:
+ out^, ok = resolve_type_expression(ast_context, v.x)
+ return ok
case:
log.warnf("default node kind, internal_resolve_type_expression: %v", v)
}
diff --git a/tests/hover_test.odin b/tests/hover_test.odin
index 5c7b74c..9001300 100644
--- a/tests/hover_test.odin
+++ b/tests/hover_test.odin
@@ -4390,6 +4390,16 @@ ast_hover_keyword_transmute :: proc(t: ^testing.T) {
}
test.expect_hover(t, &source, "transmute(T)v\nBitwise cast between 2 types of the same size.")
}
+
+@(test)
+ast_hover_ternary :: proc(t: ^testing.T) {
+ source := test.Source {
+ main = `package test
+ fo{*}o :: true ? 1 : 2
+ `
+ }
+ test.expect_hover(t, &source, "test.foo: int")
+}
/*
Waiting for odin fix