Widening of booleans causes bad results

XMLWordPrintable

    • b122
    • generic
    • generic
    • Verified

        Widening of types allows widening of boolean to int. This causes undesirable results with both ternary operator and return values of functions. Both examples below print "1", when they should print "true":

        print((function (x) { return x ? true : 0 })(true))
        print((function (x) { if(x) { return true } else { return 0 } })(true))

              Assignee:
              Attila Szegedi
              Reporter:
              Attila Szegedi
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: