diff options
| -rw-r--r-- | build.bat | 6 | ||||
| -rwxr-xr-x | build.sh | 4 | ||||
| -rw-r--r-- | src/server/generics.odin | 19 | ||||
| -rw-r--r-- | tests/completions_test.odin | 23 |
4 files changed, 47 insertions, 5 deletions
@@ -2,11 +2,11 @@ setlocal enabledelayedexpansion
if "%1" == "test" (
- odin test tests -collection:src=src -debug -define:ODIN_TEST_THREADS=1
+ odin test tests -collection:src=src -debug -define:ODIN_TEST_THREADS=1 -define:ODIN_TEST_TRACK_MEMORY=false
) else if "%1" == "single_test" (
- odin test tests -collection:src=src -define:ODIN_TEST_NAMES=%2 -debug
+ odin test tests -collection:src=src -define:ODIN_TEST_NAMES=%2 -define:ODIN_TEST_TRACK_MEMORY=false -debug
) else if "%1" == "debug" (
- odin build src\ -show-timings -collection:src=src -microarch:native -out:ols.exe -o:minimal -no-bounds-check -use-separate-modules -debug
+ odin build src\ -show-timings -microarch:native -collection:src=src -out:ols.exe -o:minimal -no-bounds-check -use-separate-modules -debug
) else (
odin build src\ -show-timings -microarch:native -collection:src=src -out:ols.exe -o:speed -no-bounds-check
)
@@ -8,7 +8,7 @@ then #BUG in odin test, it makes the executable with the same name as a folder and gets confused. cd tests - odin test ../tests -collection:src=../src -test-name:$@ -define:ODIN_TEST_THREADS=1 + odin test ../tests -collection:src=../src -test-name:$@ -define:ODIN_TEST_THREADS=1 -define:ODIN_TEST_TRACK_MEMORY=false shift @@ -28,7 +28,7 @@ then #BUG in odin test, it makes the executable with the same name as a folder and gets confused. cd tests - odin test ../tests -collection:src=../src $@ -define:ODIN_TEST_THREADS=1 + odin test ../tests -collection:src=../src $@ -define:ODIN_TEST_THREADS=1 -define:ODIN_TEST_TRACK_MEMORY=false if ([ $? -ne 0 ]) then diff --git a/src/server/generics.odin b/src/server/generics.odin index 8c8a5a2..ffb3cb6 100644 --- a/src/server/generics.odin +++ b/src/server/generics.odin @@ -495,6 +495,25 @@ resolve_generic_function_symbol :: proc( return {}, false } + //If we have a function call, we should instead look at the return value: bar(foo(123)) + if symbol_value, ok := symbol.value.(SymbolProcedureValue); ok && len(symbol_value.return_types) > 0 { + if _, ok := call_expr.args[i].derived.(^ast.Call_Expr); ok { + if symbol_value.return_types[0].type != nil { + if symbol, ok = resolve_type_expression(ast_context, symbol_value.return_types[0].type); + ok { + symbol_expr = symbol_to_expr( + symbol, + call_expr.args[i].pos.file, + context.temp_allocator, + ) + if symbol_expr == nil { + return {}, false + } + } + } + } + } + symbol_expr = clone_expr(symbol_expr, ast_context.allocator, nil) param_type := clone_expr(param.type, ast_context.allocator, nil) diff --git a/tests/completions_test.odin b/tests/completions_test.odin index b695732..b97ba1a 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -2973,3 +2973,26 @@ ast_switch_completion_multiple_cases :: proc(t: ^testing.T) { test.expect_completion_details(t, &source, "", {}) } + + +@(test) +ast_generics_chained_procedures :: proc(t: ^testing.T) { + source := test.Source { + main = `package main + foo :: proc (v: int) -> int { + return v + } + + bar :: proc (v: $T) -> T { + return v + } + + main :: proc () { + valzz := bar(foo(123)) + valz{*} + } + `, + } + + test.expect_completion_details(t, &source, "", {"test.valzz: int"}) +} |