bug_issue_1496.js 954 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. // GitHub Issue1496: ES6 constructor returns class instead of object upon constructorCache hit
  6. //
  7. // -mic:1 -maxsimplejitruncount:2
  8. var Test = {};
  9. class A {
  10. constructor(foo) { this.foo = foo; }
  11. toB() {
  12. return new Test.B(this);
  13. }
  14. }
  15. class B {
  16. constructor(bar) { this.bar = bar; }
  17. }
  18. Test.B = B;
  19. for (var i=0; i<10; i++)
  20. {
  21. var a = new A(i);
  22. var b = a.toB();
  23. try
  24. {
  25. WScript.Echo(b.bar.foo);
  26. }
  27. catch (e)
  28. {
  29. WScript.Echo(e);
  30. WScript.Echo(b);
  31. break;
  32. }
  33. }