michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: function f() { michael@0: return function(a) { michael@0: // This eval must take place before the block is cloned, when the michael@0: // call object is still not marked as a delegate. The scope chain michael@0: // purge for the JSOP_DEFVAR will not change the global's shape, michael@0: // and the property cache entry will remain valid. michael@0: eval(a); michael@0: let (c = 3) { michael@0: // This eval forces the block to be cloned, so its shape gets michael@0: // used as the property cache key shape. michael@0: eval(''); michael@0: return b; michael@0: }; michael@0: }; michael@0: } michael@0: michael@0: var b = 1; michael@0: var g1 = f(); michael@0: var g2 = f(); michael@0: michael@0: /* Call the lambda once, caching a reference to the global b. */ michael@0: g1(''); michael@0: michael@0: /* michael@0: * If this call sees the above cache entry, then it will erroneously use the michael@0: * global b. michael@0: */ michael@0: assertEq(g2('var b=2'), 2); michael@0: michael@0: reportCompare(true, true);