DanielGavin / ols

Language server for Odin
MIT License
375 stars 56 forks source link

Items involving generic functions fail to return results depending on package scope. #386

Closed dmitsuki closed 1 month ago

dmitsuki commented 1 month ago

Essentially title. When an item is returned from a generic function the ability for ols to parse it seems to change based on scope.

main.odin

package main

import "testpackage"

CoolStruct :: struct
{
    val1, val2, val3: int,
}

main :: proc()
{
    testArray := make([dynamic]CoolStruct);
    otherTestArray := make([dynamic]testpackage.OtherStruct);

    //no completion on function or new value
    newValue := testpackage.DummyFunction(testArray, 10);
    newValue.val1 = 1;

    //Compleition works
    newerValue := testpackage.DummyFunction(otherTestArray, 10);
    newerValue.val1 = 10;
}

testpackage/testpackage.odin

package testpackage

OtherStruct :: struct 
{
    val1, val2, val3: int,
}

DummyFunction :: proc(value: $T/[dynamic]$E, index: int) -> ^E
{
    return &value[index]
}

minirepo.zip

DanielGavin commented 1 month ago

Should be fixed.

dmitsuki commented 1 month ago

It still fails on this case for me

main.odin


package main

import "core:fmt"
import "testpackage"

CoolStruct :: struct
{
    val1, val2, val3: int,
}

main :: proc()
{
    //no completion on function or new value
    newValue := testpackage.DummyFunction(CoolStruct, CoolStruct{});
    newValue.val1 = 1;

    //Compleition works
    newerValue := testpackage.DummyFunction(testpackage.OtherStruct, testpackage.OtherStruct{});
    newerValue.val1 = 10;
    fmt.println("success");

}

testpackage/testpackage.odin

package testpackage

OtherStruct :: struct 
{
    val1, val2, val3: int,
}

DummyFunction :: proc($T: typeid, value: T) -> T
{
    return value;
}
DanielGavin commented 1 month ago

Try again.

dmitsuki commented 1 month ago

That seems to have fixed it, thanks!