odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.55k stars 570 forks source link

Implicit Selector Expressions do not work with overloaded procedures #403

Closed vassvik closed 5 years ago

vassvik commented 5 years ago

Implicit Selector Expressions do not work with overloaded procedures. Minimal standalone example:

package main 

main :: proc() {
    Bar :: enum {A}

    foo1 :: proc(a: int, b: Bar) {}
    foo2 :: proc(a: string, b: Bar) {}
    foo :: proc{foo1, foo2};

    foo1(1, .A);
    foo2("", .A);
    foo(1, Bar.A);
    foo("", Bar.A);
    foo(1, .A);  // Cannot determine type for implicit selector expression '.A'
    foo("", .A); // Cannot determine type for implicit selector expression '.A'
}

Full error:

main.odin(14:13) Cannot determine type for implicit selector expression '.A'
main.odin(14:5) No procedures or ambiguous call for procedure group 'foo' that match with the given arguments
    Given argument types: (untyped integer, invalid type)
Did you mean to use one of the following:
    main.foo1 :: proc(a: int, b: Bar) at main.odin(6:5)
    main.foo2 :: proc(a: string, b: Bar) at main.odin(7:5)
gingerBill commented 5 years ago

This is not technically a bug the more I actually look at it but rather just a lack of rules defined for procedure groups.

gingerBill commented 5 years ago

I have added support for this now in previous commit https://github.com/odin-lang/Odin/commit/56d365a4e70076320386bb2f1f401cc8949c568f

However, this will not work for named arguments as of yet.

gingerBill commented 5 years ago

I have no added support for this too:

foo(a=1, b=.A);  
foo(a="", .b=A);