DanielGavin / ols

Language server for Odin
MIT License
417 stars 62 forks source link

Union Assert Completion not using Renamed Imports #240

Closed blob1807 closed 1 year ago

blob1807 commented 1 year ago

Issue

Renamed Imports aren't being used in the VSCode ext's Code Completion for Union Assertions. Instead the og package name is. Compiler will Error out if current completion is used. I've not tested it in other editors. Nor if it happens in other areas.

Versions

ols: v0.1.21 Odin: dev-2023-08 VSCode: 1.81.1 OS: Windows 10 22H2 19045.3324

Example

./main.odin

package main
import bar "food"

main :: proc() {
    // Current code completion
    cake := bar.fight(0).(food.Cakes)
    pies := bar.fight(1).(food.Pies)
    glass := bar.fight(2).(food.Glass)

    // What it should be
    _cake := bar.fight(0).(bar.Cakes)
    _pies := bar.fight(1).(bar.Pies)
    _glass := bar.fight(2).(bar.Glass)
}

./food/food.odin

package food
Cakes :: string
Pies :: bool
Glass :: enum {Wine, Stout, Whisky,}
Items :: union {Cakes, Pies, Glass,}
fight :: proc(t: int) -> Items {
    switch t {
        case 0: return "Sweet Rolls"
        case 1: return true
        case 2: return Glass.Stout
        case:   return nil
    }
}

Current Completion

DanielGavin commented 1 year ago

Should be fixed now.