diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-07-30 02:47:11 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-07-30 02:47:11 +0200 |
| commit | 9ea6cb14bba72c01d16ba35f8ef697b90819a2ae (patch) | |
| tree | 2e52bc6c293ed2a11b1f7e4c565427182766dd0f | |
| parent | 992edc6330e07e5e63b867fc34ebf30250d6dabd (diff) | |
| parent | ce72f77b455afa6a7de26b74de4ca539aeffecd6 (diff) | |
Merge branch 'master' of github.com:DanielGavin/ols
| -rw-r--r-- | src/odin/printer/visit.odin | 4 | ||||
| -rw-r--r-- | src/server/analysis.odin | 2 | ||||
| -rw-r--r-- | tests/completions_test.odin | 20 | ||||
| -rw-r--r-- | tools/odinfmt/tests/.snapshots/assignments.odin | 5 | ||||
| -rw-r--r-- | tools/odinfmt/tests/assignments.odin | 5 |
5 files changed, 34 insertions, 2 deletions
diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index 04d1ada..a76ab47 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -1045,9 +1045,9 @@ visit_expr :: proc(p: ^Printer, expr: ^ast.Expr, called_from: Expr_Called_Type = document = cons_with_opl(document, group(visit_expr(p, v.y))) } case ^Ternary_When_Expr: - document = visit_expr(p, v.cond) + document = visit_expr(p, v.x) document = cons_with_nopl(document, text_token(p, v.op1)) - document = cons_with_nopl(document, visit_expr(p, v.x)) + document = cons_with_nopl(document, visit_expr(p, v.cond)) document = cons_with_nopl(document, text_token(p, v.op2)) document = cons_with_nopl(document, visit_expr(p, v.y)) case ^Or_Else_Expr: diff --git a/src/server/analysis.odin b/src/server/analysis.odin index bd4f7d4..9be28dd 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -154,6 +154,8 @@ get_poly_node_to_expr :: proc(node: ^ast.Node) -> ^ast.Expr { #partial switch v in node.derived { case ^Ident: return cast(^Expr)node + case ^Comp_Lit: + return v.type case: log.warnf("Unhandled poly to node kind %v", v) } diff --git a/tests/completions_test.odin b/tests/completions_test.odin index f9e93da..5fda923 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -1349,6 +1349,26 @@ ast_new_completion :: proc(t: ^testing.T) { } @(test) +ast_new_clone_completion :: proc(t: ^testing.T) { + source := test.Source { + main = `package main + new_clone :: proc(data: $T) -> (^T, Allocator_Error) #optional_second { + } + + Foo :: struct {} + + main :: proc() { + adzz := new_clone(Foo{}); + adzz* + } + + `, + }; + + test.expect_completion_details(t, &source, "", {"test.adzz: Foo"}); +} + +@(test) ast_rawtr_cast_completion :: proc(t: ^testing.T) { source := test.Source { main = `package main diff --git a/tools/odinfmt/tests/.snapshots/assignments.odin b/tools/odinfmt/tests/.snapshots/assignments.odin index 7b09796..983087e 100644 --- a/tools/odinfmt/tests/.snapshots/assignments.odin +++ b/tools/odinfmt/tests/.snapshots/assignments.odin @@ -11,3 +11,8 @@ assignments :: proc() { &big.Int{} } + +ternary_when_assignment :: proc() { + a := WGL_CONTEXT_FLAGS_ARB when ODIN_DEBUG else 0 + b := ODIN_DEBUG ? WGL_CONTEXT_FLAGS_ARB : 0 +} diff --git a/tools/odinfmt/tests/assignments.odin b/tools/odinfmt/tests/assignments.odin index c90b04e..53cc9aa 100644 --- a/tools/odinfmt/tests/assignments.odin +++ b/tools/odinfmt/tests/assignments.odin @@ -4,3 +4,8 @@ assignments :: proc() { a, b, c, d, e, f, res := &big.Int{}, &big.Int{}, &big.Int{}, &big.Int{}, &big.Int{}, &big.Int{}, &big.Int{} } + +ternary_when_assignment :: proc() { + a := WGL_CONTEXT_FLAGS_ARB when ODIN_DEBUG else 0 + b := ODIN_DEBUG ? WGL_CONTEXT_FLAGS_ARB : 0 +} |