Details
Description
Consider an (badly named) API having a method like bool IsFoo().
If one uses that method in a condition, but in thinking it is a property (ie. if x.IsFoo), then Boo will treat it as an 'implicit' callable and thus the condition will always be true.
The only way to notice that error is by seeing unexpected results at run-time :s
cedric@laptop:~/dev/workspace/boo/boo$ cat tests/testcases/regression/BOO-1087-1.boo """ :) :D """ static class StaticBadNaming: def IsGood(): return false class BadNaming: def IsGood(): return false if StaticBadNaming.IsGood: #IsGood is a callable, condition is true print ":(" else: print ":)" bad = BadNaming() if bad.IsGood: #IsGood is a callable, condition is true print ":'(" else: print ":D" cedric@laptop:~/dev/workspace/boo/boo$ booc tests/testcases/regression/BOO-1087-1.boo Boo Compiler version 0.8.2.3038 (CLR v2.0.50727.1433) cedric@laptop:~/dev/workspace/boo/boo$ ./BOO-1087-1.exe :( :'(
Boo should emit a warning when a implicit callable is used in a boolean context.
Or actually should implicit callables be allowed in a boolean context at all ?? (I'm not sure how it is useful?)
Issue Links
| This issue relates to: | ||||
| BOO-1115 | Strict mode |
|
|
|
Sounds like a good idea to provide a warning, at least.