fieldhoist_kills.js 784 B

12345678910111213141516171819
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. // - 'o2' is hoisted outside the loop
  6. // - 'test0b' is inlined
  7. // - 'o2 = 0' should kill 'o2' in the inliner function 'test0', causing the loop to exit early
  8. function test0() {
  9. var o1 = { p: 0 };
  10. var o2 = { p: 4 };
  11. for(; o1.p < o2.p; ++o1.p)
  12. test0b();
  13. return o1.p;
  14. function test0a() { eval(""); }
  15. function test0b() { o2 = 0; }
  16. }
  17. WScript.Echo("test0: " + test0());