Oxygen Basic

Programming => Bugs & Feature Requests => Topic started by: Brian Alvarez on January 12, 2019, 10:22:38 PM

Title: Another small issue with parameter matching...
Post by: Brian Alvarez on January 12, 2019, 10:22:38 PM
If it doesnt find an exact match, it just takes the last one, instead of the one that matches the most:

Code: [Select]
FUNCTION sources() as wstring
    wstring ss = "source"
    return ss
END FUNCTION

function handler(wstring ss, wstring d = "unicode!") as long ' this one should be used....
    print "UNICODE HANDLER: " + ss
end function

function handler(string ss, string d = "ANSI!") as long ' instead uses this one.
    print "ANSI HANDLER: " + ss
end function

handler sources()
Title: Re: Another small issue with parameter matching...
Post by: Brian Alvarez on January 12, 2019, 10:31:39 PM
Here is another example, i think the isssue is more evident, because it has 2 ANSI strings, yet, the unicode handler is picked:

Code: [Select]
FUNCTION sources() as string
    string ss = "source"
    return ss
END FUNCTION

function handler(string ss, string d = "ANSI!") as long
    print "ANSI HANDLER: " + ss
end function

function handler(wstring ss, wstring d = "unicode!") as long
    print "UNICODE HANDLER: " + ss
end function

handler sources(), "ansi string!"
Title: Re: Another small issue with parameter matching...
Post by: Charles Pegge on January 12, 2019, 11:11:24 PM
There is a conflict between function-overloading and default parameters. When evaluating a match, function-overloading only works with definite parameters.