newsideeffect.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 echo(m) { this.WScript ? WScript.Echo(m) : console.log(m); }
  6. //
  7. // Win8: 762166
  8. // ES5 11.2.2 "new MemberExpression Arguments", MemberExpression is fully evaluated before Arguments.
  9. // Arguments side effect can't change the constructor used for new operator.
  10. //
  11. (function(){
  12. function x(){ echo("x");}
  13. function y(){ echo("y");}
  14. new x(x = y);
  15. new x();
  16. })();
  17. (function(){
  18. function x(){ echo("x");}
  19. function y(){ echo("y");}
  20. new x(x = y);
  21. new x();
  22. function foo() {
  23. x(); // Reference of "x" and put it in slot
  24. }
  25. })();
  26. (function () {
  27. var o = {
  28. x: function () { echo("x"); }
  29. };
  30. function y() { echo("y"); }
  31. new o.x(o.x = y);
  32. new o.x();
  33. })();
  34. (function () {
  35. var o = {
  36. x: function () { echo("x"); }
  37. };
  38. var y = {
  39. x: function () { echo("y"); }
  40. };
  41. new o.x(o = y);
  42. new o.x();
  43. })();