Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8006570

this-value for non-strict functions should be converted to object

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • None
    • core-libs
    • None

      Step 3 of ES 10.4.3 (Entering Function Code) requires that primitive this-values in non-strict functions must be converted to object. However, Nashorn currently prints "number" and "string" instead of 2x "object" for the code below:

      Object.prototype.x = function() {
          print(typeof this);
      };
      (123).x();
      "foo".x();

      I was wondering how this could go unnoticed by test262, which has 200 tests for ES 10.4.3. It turns out that test262 only tests this within a property descriptor getter (ch10/10.4/10.4.3/10.4.3-1-105.js), which is the one case where Nashorn doesn't exhibit this bug.

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

              Created:
              Updated:
              Resolved: