For an UDT with a member operator Cast to String, an instance passed as argument is well implicitly converted to string when calling Instr() and Mid(), but not when calling Left() and Right():
Type UDT Declare Operator Cast() As String Dim As Integer I End Type Operator UDT.cast() As String Return Str(This.I) End Operator Dim As UDT u u.I = 123 Print Mid(u, 2) Print Instr(u, "2") Print Left(u, 2) Print Right(u, 2)
error 97: Ambiguous call to overloaded function, LEFT() in 'Print Left(u, 2)'
error 97: Ambiguous call to overloaded function, RIGHT() in 'Print Right(u, 2)'
Same behavior for ZString and WString.
Example for WString:
error 97: Ambiguous call to overloaded function, LEFT() in 'Print Left(u, 2)'
error 97: Ambiguous call to overloaded function, RIGHT() in 'Print Right(u, 2)'
Last edit: fxm (freebasic.net) 2016-12-10
That also does not work with Val().
Related to [#666]
Pull request at github # 332 Allow overloads for z|w string ptr types and conversions for UDT's casting z|w string ptr types
Fixed in fbc 1.09.0 [4dda1eaab5d9c0f86e44045fcd7540dcfd57709b]
Note:
I just noticed the last message from fxm : 'that also does not work with Val()'
I didn't write any tests specifically for Val(), but this fix also addresses the issue with Val() - it's the same issue as with Left()/Right().
Related
Bugs:
#666Commit: [4dda1e]