michael@0: let expected = 'o!o!o!'; michael@0: let actual = ''; michael@0: michael@0: // g is a function that needs an implicit |this| if called within a |with| michael@0: // statement. If we fail to provide that implicit |this|, it will append michael@0: // "[object global]" instead of "o!". michael@0: let o = { michael@0: g: function() { actual += this.toString(); }, michael@0: toString: function() { return "o!"; } michael@0: } michael@0: michael@0: // g's presence within the |with| is detected by simple tracking of |with|s michael@0: // during parsing. michael@0: with (o) { michael@0: (function() { g(); })(); michael@0: } michael@0: michael@0: // The eval() defeats the tracking of |with| during parsing. Instead, g's michael@0: // presence within the |with| is detected by looking at the scopeChain of the michael@0: // ParseContext. michael@0: with (o) { michael@0: eval("(function() { g(); })()"); michael@0: } michael@0: michael@0: // This is like the above case, but the knowledge of the |with| presence must michael@0: // be inherited by the inner function. This is the case that was missed in bug michael@0: // 786114. michael@0: with (o) { michael@0: eval("(function() { (function() { g(); })(); })()"); michael@0: } michael@0: michael@0: assertEq(actual, expected);