this vs thi\u0073

Mike Samuel mikesamuel at gmail.com
Mon Jun 20 13:53:03 PDT 2011


I was mucking around with some tests of how interpreters deal with
identifiers whose decoded value is the same as a reserved keyword.

Many interpreters seem to diverge wildly from the spec and from each
other w.r.t. encoded versions of the keyword "this".

I don't see any relationship between the identifier "this" and
ThisBinding in the spec, so I believe the below tests should all pass.
 Am I missing something?

The testcases are available at
http://google-caja.googlecode.com/svn/trunk/doc/html/identifier-keyword-confusion.html
and are reproduced below for easy quoting:


      assertTrue("this" === "thi\u0073");

      (function () {
        var thi\u0073 = 42;
        assertFalse(this === 42);
        assertTrue(thi\u0073 === 42);
      }());

      (function (thi\u0073) {
        assertFalse(this === 42);
        assertTrue(thi\u0073 === 42);
      }(42));

      (function thi\u0073() {
        assertFalse("function" === typeof this);
        assertTrue("function" === typeof thi\u0073);
      }());

      var called = false, bodyReached = false;
      var \u0069\u0066 = function (x) { assertFalse(x); called = true; };

      assertTrue("if" === "\u0069\u0066");

      \u0069\u0066(false)
      {
        bodyReached = true;
      }
      assertTrue(called);
      assertTrue(bodyReached);


More information about the es-discuss mailing list