Specialized functions convert booleans to numbers

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 9
    • Affects Version/s: 9
    • Component/s: core-libs
    • None
    • b148
    • generic
    • generic

      Because the boolean type is considered narrower than numeric types in Nashorn it is possible to invoke builtin specialized functions that accept numeric params with boolean arguments. In many cases this leads to the correct result as arguments are converted to numbers anyway, but in the case of Array.prototype.concat and Array.prototype.push the result is wrong.

      var array = [].concat(true); // array is [1], should be [true]
      array.push(false); // array is [1, 0], should be [true, false]

      This only occurs with optimistic types enabled.

            Assignee:
            Hannes Wallnoefer
            Reporter:
            Hannes Wallnoefer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: