withnonativeApplyOptimizationBug3433559.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. var foo = function(){}
  6. function letTest() {
  7. let sc1 = 0;
  8. with({})
  9. {
  10. sc1 = foo;
  11. sc1();
  12. }
  13. this.method0.apply(this, arguments);
  14. }
  15. function constTest() {
  16. const sc1 = 0;
  17. with({})
  18. {
  19. sc1 = foo;
  20. sc1();
  21. }
  22. this.method0.apply(this, arguments);
  23. }
  24. function varTest() {
  25. with({})
  26. {
  27. var sc1 = foo;
  28. sc1();
  29. }
  30. this.method0.apply(this, arguments);
  31. }
  32. function TryFunction(f)
  33. {
  34. try
  35. {
  36. f();
  37. }catch (e) {
  38. if (e instanceof TypeError) { // Unable to get property 'apply' of undefined or null reference (method0)
  39. return true;
  40. }
  41. if (e instanceof ReferenceError) { // Assignment to const
  42. return true;
  43. }
  44. }
  45. }
  46. if(TryFunction(letTest) && TryFunction(constTest) && TryFunction(varTest))
  47. {
  48. print("Pass");
  49. }