test-bug-function-this.nut 624 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. class Klass {
  2. k_member = null;
  3. constructor(){
  4. k_member = 0;
  5. }
  6. function showbug(){
  7. local function bug(v){
  8. print("bug", v)
  9. k_member = v;
  10. print("assignment done", k_member);
  11. return "hhhh";
  12. }
  13. bug.setenv(this);
  14. bug("ok from here");
  15. local ar = ["arvalue"];
  16. ar.apply(bug);
  17. }
  18. }
  19. function showbug(){
  20. local k_member = 0;
  21. local function bug(v){
  22. print("bug len", len());
  23. print("bug", v)
  24. k_member = v;
  25. print("assignment done", k_member);
  26. return "hhhh";
  27. }
  28. bug("ok from here");
  29. local ar = ["arvalue"];
  30. ar.apply(bug);
  31. }
  32. showbug();
  33. local k = Klass();
  34. k.showbug();