popImplicitCall.js 839 B

1234567891011121314151617181920212223242526272829303132
  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. function foo()
  6. {
  7. var obj = {};
  8. Object.prototype.push = Array.prototype.push;
  9. Object.prototype.pop = Array.prototype.pop;
  10. var x;
  11. Object.defineProperty(obj, "length", {get: function() {x = true; return 5;}});
  12. x = false;
  13. try
  14. {
  15. var len = obj.pop();
  16. }
  17. catch (e)
  18. {
  19. WScript.Echo('caught exception calling pop');
  20. }
  21. WScript.Echo(x);
  22. WScript.Echo(len);
  23. }
  24. (foo());foo();