Patch 8.2.2018
Problem:    Vim9: script variable not found from lambda.
Solution:   In a lambda also check the script hashtab for a variable without a
            scope. (closes #7329)
Files:      src/evalvars.c, src/testdir/test_vim9_func.vim


*** ../vim-8.2.2017/src/evalvars.c      2020-11-04 11:36:31.412190527 +0100
--- src/evalvars.c      2020-11-19 21:39:26.511760858 +0100
***************
*** 2628,2634 ****
        return ret;
  
      // Search in parent scope for lambda
!     return find_var_in_scoped_ht(name, no_autoload || htp != NULL);
  }
  
  /*
--- 2628,2655 ----
        return ret;
  
      // Search in parent scope for lambda
!     ret = find_var_in_scoped_ht(name, no_autoload || htp != NULL);
!     if (ret != NULL)
!       return ret;
! 
!     // in Vim9 script items without a scope can be script-local
!     if (in_vim9script() && name[0] != NUL && name[1] != ':')
!     {
!       ht = get_script_local_ht();
!       if (ht != NULL)
!       {
!           ret = find_var_in_ht(ht, *name, varname,
!                                                  no_autoload || htp != NULL);
!           if (ret != NULL)
!           {
!               if (htp != NULL)
!                   *htp = ht;
!               return ret;
!           }
!       }
!     }
! 
!     return NULL;
  }
  
  /*
*** ../vim-8.2.2017/src/testdir/test_vim9_func.vim      2020-11-19 
18:53:15.188492574 +0100
--- src/testdir/test_vim9_func.vim      2020-11-19 21:44:36.722731858 +0100
***************
*** 1476,1481 ****
--- 1476,1490 ----
    Line_continuation_in_def('.')->assert_equal('full')
  enddef
  
+ def Test_script_var_in_lambda()
+   var lines =<< trim END
+       vim9script
+       var script = 'test'
+       assert_equal(['test'], map(['one'], {-> script}))
+   END
+   CheckScriptSuccess(lines)
+ enddef
+ 
  def Line_continuation_in_lambda(): list<string>
    var x = range(97, 100)
        ->map({_, v -> nr2char(v)
*** ../vim-8.2.2017/src/version.c       2020-11-19 19:01:39.746594508 +0100
--- src/version.c       2020-11-19 21:40:33.599538058 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2018,
  /**/

-- 
The software said it requires Windows 95 or better, so I installed Linux.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202011192050.0AJKo4nv453136%40masaka.moolenaar.net.

Raspunde prin e-mail lui