Details
Description
[extension]
def op_Implicit(s as string):
return not string.IsNullOrEmpty(s)
x = ""
y = "foo"
print x or y
Above code prints "True" instead of "foo".
In a logical operator bool context the implicit "to bool" must be used only to evaluate operand trueness.
Also if an op_Implicit extension exists on a type, the extension must be chosen in priority over the built-in implicit conversion.
Testcase:
""" OK OK """ [extension] def op_Implicit(s as string) as bool: return s.Length > 1 [extension] #nullables have a builtin implicit conversion too def op_Implicit(x as int?) as bool: return not x.HasValue x = "x" y = "OK" print x or y #"OK" instead of "x" a as int? = 10 b as int? = 20 print a or b #20 instead of 10
Fixed in rev. 3199