Patch 8.2.1012
Problem:    Vim9: cannot declare single character script variables.
Solution:   Don't see "b:", "s:", etc. as namespace.  Fix item size of
            sn_var_vals.
Files:      src/vim9script.c, src/scriptfile.c,
            src/testdir/test_vim9_script.vim


*** ../vim-8.2.1011/src/vim9script.c    2020-06-19 18:34:10.989945091 +0200
--- src/vim9script.c    2020-06-19 18:43:44.024372609 +0200
***************
*** 471,477 ****
      }
  
      for (p = arg + 1; *p != NUL && eval_isnamec(*p); MB_PTR_ADV(p))
!       if (*p == ':' && p != arg + 1)
            break;
  
      if (*p != ':')
--- 471,477 ----
      }
  
      for (p = arg + 1; *p != NUL && eval_isnamec(*p); MB_PTR_ADV(p))
!       if (*p == ':' && (VIM_ISWHITE(p[1]) || p != arg + 1))
            break;
  
      if (*p != ':')
*** ../vim-8.2.1011/src/scriptfile.c    2020-05-25 22:36:46.629735032 +0200
--- src/scriptfile.c    2020-06-19 18:51:22.423708670 +0200
***************
*** 1343,1349 ****
  
            // Allocate the local script variables to use for this script.
            new_script_vars(script_items.ga_len);
!           ga_init2(&si->sn_var_vals, sizeof(typval_T), 10);
            ga_init2(&si->sn_imports, sizeof(imported_T), 10);
            ga_init2(&si->sn_type_list, sizeof(type_T), 10);
  # ifdef FEAT_PROFILE
--- 1343,1349 ----
  
            // Allocate the local script variables to use for this script.
            new_script_vars(script_items.ga_len);
!           ga_init2(&si->sn_var_vals, sizeof(svar_T), 10);
            ga_init2(&si->sn_imports, sizeof(imported_T), 10);
            ga_init2(&si->sn_type_list, sizeof(type_T), 10);
  # ifdef FEAT_PROFILE
*** ../vim-8.2.1011/src/testdir/test_vim9_script.vim    2020-06-19 
18:34:10.993945080 +0200
--- src/testdir/test_vim9_script.vim    2020-06-19 18:59:58.442718650 +0200
***************
*** 109,114 ****
--- 109,149 ----
    call CheckDefFailure(['v:errmsg += 123'], 'E1013:')
  enddef
  
+ def Test_vim9_single_char_vars()
+   let lines =<< trim END
+       vim9script
+ 
+       " single character variable declarations work
+       let a: string
+       let b: number
+       let l: list<any>
+       let s: string
+       let t: number
+       let v: number
+       let w: number
+ 
+       " script-local variables can be used without s: prefix
+       a = 'script-a'
+       b = 111
+       l = [1, 2, 3]
+       s = 'script-s'
+       t = 222
+       v = 333
+       w = 444
+ 
+       assert_equal('script-a', a)
+       assert_equal(111, b)
+       assert_equal([1, 2, 3], l)
+       assert_equal('script-s', s)
+       assert_equal(222, t)
+       assert_equal(333, v)
+       assert_equal(444, w)
+   END
+   writefile(lines, 'Xsinglechar')
+   source Xsinglechar
+   delete('Xsinglechar')
+ enddef
+ 
  def Test_assignment_list()
    let list1: list<bool> = [false, true, false]
    let list2: list<number> = [1, 2, 3]
*** ../vim-8.2.1011/src/version.c       2020-06-19 18:34:10.993945080 +0200
--- src/version.c       2020-06-19 18:51:50.367663985 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1012,
  /**/

-- 
TALL KNIGHT: When you have found the shrubbery, then you must cut down the
             mightiest tree in the forest ... with a herring.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/202006191702.05JH28Et657327%40masaka.moolenaar.net.

Raspunde prin e-mail lui