Patch 8.2.0486
Problem:    Vim9: some code and error messages not tested.
Solution:   Add more tests.
Files:      src/vim9compile.c, src/evalvars.c, src/testdir/test_vim9_expr.vim,
            src/testdir/test_vim9_script.vim


*** ../vim-8.2.0485/src/vim9compile.c   2020-03-30 21:28:35.413310419 +0200
--- src/vim9compile.c   2020-03-30 22:48:10.612630190 +0200
***************
*** 3353,3361 ****
      }
      else
      {
!       if (set_return_type)
!           cctx->ctx_ufunc->uf_ret_type = &t_void;
!       else if (cctx->ctx_ufunc->uf_ret_type->tt_type != VAR_VOID)
        {
            emsg(_("E1003: Missing return value"));
            return NULL;
--- 3353,3361 ----
      }
      else
      {
!       // "set_return_type" cannot be TRUE, only used for a lambda which
!       // always has an argument.
!       if (cctx->ctx_ufunc->uf_ret_type->tt_type != VAR_VOID)
        {
            emsg(_("E1003: Missing return value"));
            return NULL;
***************
*** 3416,3422 ****
      cctx_T  *cctx = (cctx_T *)cookie;
  
      if (cctx->ctx_lnum == cctx->ctx_ufunc->uf_lines.ga_len)
!       NULL;
      ++cctx->ctx_lnum;
      return vim_strsave(((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)
                                                             [cctx->ctx_lnum]);
--- 3416,3425 ----
      cctx_T  *cctx = (cctx_T *)cookie;
  
      if (cctx->ctx_lnum == cctx->ctx_ufunc->uf_lines.ga_len)
!     {
!       iemsg("Heredoc got to end");
!       return NULL;
!     }
      ++cctx->ctx_lnum;
      return vim_strsave(((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)
                                                             [cctx->ctx_lnum]);
***************
*** 3472,3477 ****
--- 3475,3484 ----
        return NULL;
      }
  
+     // "a: type" is declaring variable "a" with a type, not "a:".
+     if (is_decl && p == arg + 2 && p[-1] == ':')
+       --p;
+ 
      varlen = p - arg;
      name = vim_strnsave(arg, (int)varlen);
      if (name == NULL)
***************
*** 3499,3504 ****
--- 3506,3512 ----
            p = find_option_end(&p, &opt_flags);
            if (p == NULL)
            {
+               // cannot happen?
                emsg(_(e_letunexp));
                return NULL;
            }
***************
*** 3508,3514 ****
            *p = cc;
            if (opt_type == -3)
            {
!               semsg(_(e_unknown_option), *arg);
                return NULL;
            }
            if (opt_type == -2 || opt_type == 0)
--- 3516,3522 ----
            *p = cc;
            if (opt_type == -3)
            {
!               semsg(_(e_unknown_option), arg);
                return NULL;
            }
            if (opt_type == -2 || opt_type == 0)
*** ../vim-8.2.0485/src/evalvars.c      2020-03-29 15:12:11.937482074 +0200
--- src/evalvars.c      2020-03-30 22:11:00.857885519 +0200
***************
*** 930,936 ****
            {
                if (*semicolon == 1)
                {
!                   emsg(_("Double ; in list of variables"));
                    return NULL;
                }
                *semicolon = 1;
--- 930,936 ----
            {
                if (*semicolon == 1)
                {
!                   emsg(_("E452: Double ; in list of variables"));
                    return NULL;
                }
                *semicolon = 1;
*** ../vim-8.2.0485/src/testdir/test_vim9_expr.vim      2020-03-30 
21:22:52.014545238 +0200
--- src/testdir/test_vim9_expr.vim      2020-03-30 21:44:08.938218612 +0200
***************
*** 58,63 ****
--- 58,64 ----
  
  func Test_expr1_fails()
    call CheckDefFailure("let x = 1 ? 'one'", "Missing ':' after '?'")
+   call CheckDefFailure("let x = 1 ? 'one' : xxx", "E1001:")
  
    let msg = "white space required before and after '?'"
    call CheckDefFailure("let x = 1? 'one' : 'two'", msg)
***************
*** 192,202 ****
--- 193,210 ----
    assert_equal(true, g:astring == 'asdf')
    assert_equal(false, 'xyz' == g:astring)
  
+   assert_equal(false, 'abc' == 'aBc')
+   assert_equal(false, 'abc' ==# 'aBc')
+   assert_equal(true, 'abc' ==? 'aBc')
+ 
    assert_equal(false, 'abc' == 'ABC')
    set ignorecase
    assert_equal(false, 'abc' == 'ABC')
+   assert_equal(false, 'abc' ==# 'ABC')
    set noignorecase
  
+   call CheckDefFailure("let x = 'a' == xxx", 'E1001:')
+ 
    assert_equal(true, 0z3f == 0z3f)
    assert_equal(false, 0z3f == 0z4f)
    assert_equal(true, g:ablob == 0z01ab)
*** ../vim-8.2.0485/src/testdir/test_vim9_script.vim    2020-03-28 
19:41:29.595765241 +0100
--- src/testdir/test_vim9_script.vim    2020-03-30 22:49:50.560272587 +0200
***************
*** 53,58 ****
--- 53,61 ----
    let dict4: dict<any> = #{one: 1, two: '2'}
    let dict5: dict<blob> = #{one: 0z01, tw: 0z02}
  
+   let a: number = 6
+   assert_equal(6, a)
+ 
    if has('channel')
      let chan1: channel
      let job1: job
***************
*** 101,106 ****
--- 104,124 ----
    call CheckDefFailure(['let true = 1'], 'E1034:')
    call CheckDefFailure(['let false = 1'], 'E1034:')
  
+   call CheckDefFailure(['let [a; b; c] = g:list'], 'E452:')
+ 
+   call CheckDefFailure(['let &option'], 'E1052:')
+   call CheckDefFailure(['&g:option = 5'], 'E113:')
+ 
+   call CheckDefFailure(['let $VAR = 5'], 'E1065:')
+ 
+   call CheckDefFailure(['let @~ = 5'], 'E354:')
+   call CheckDefFailure(['let @a = 5'], 'E1066:')
+ 
+   call CheckDefFailure(['let g:var = 5'], 'E1016:')
+ 
+   call CheckDefFailure(['let anr = 4', 'anr ..= "text"'], 'E1019:')
+   call CheckDefFailure(['let xnr += 4'], 'E1020:')
+ 
    call CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = 
s:notfound', 'enddef'], 'E1050:')
  
    call CheckDefFailure(['let var: list<string> = [123]'], 'expected 
list<string> but got list<number>')
***************
*** 142,147 ****
--- 160,166 ----
    call CheckDefFailure(['const var = 234', 'var = 99'], 'E1018:')
    call CheckDefFailure(['const one = 234', 'let one = 99'], 'E1017:')
    call CheckDefFailure(['const two'], 'E1021:')
+   call CheckDefFailure(['const &option'], 'E996:')
  endfunc
  
  def Test_block()
***************
*** 172,183 ****
    return g:notNumber
  enddef
  
! def Test_return_string()
    assert_equal('string', ReturnString())
    assert_equal(123, ReturnNumber())
    assert_fails('call ReturnGlobal()', 'E1029: Expected number but got string')
  enddef
  
  func Increment()
    let g:counter += 1
  endfunc
--- 191,216 ----
    return g:notNumber
  enddef
  
! def Test_return_something()
    assert_equal('string', ReturnString())
    assert_equal(123, ReturnNumber())
    assert_fails('call ReturnGlobal()', 'E1029: Expected number but got string')
  enddef
  
+ let s:nothing = 0
+ def ReturnNothing()
+   s:nothing = 1
+   if true
+     return
+   endif
+   s:nothing = 2
+ enddef
+ 
+ def Test_return_nothing()
+   ReturnNothing()
+   assert_equal(1, s:nothing)
+ enddef
+ 
  func Increment()
    let g:counter += 1
  endfunc
***************
*** 282,287 ****
--- 315,322 ----
    CheckScriptFailure(['def Func(): void', 'return "a"', 'enddef'], 'expected 
void but got string')
    CheckScriptFailure(['def Func()', 'return "a"', 'enddef'], 'expected void 
but got string')
  
+   CheckScriptFailure(['def Func(): number', 'return', 'enddef'], 'E1003:')
+ 
    CheckScriptFailure(['def Func(): list', 'return []', 'enddef'], 'E1008:')
    CheckScriptFailure(['def Func(): dict', 'return {}', 'enddef'], 'E1008:')
  enddef
*** ../vim-8.2.0485/src/version.c       2020-03-30 21:28:35.413310419 +0200
--- src/version.c       2020-03-30 21:47:54.493766122 +0200
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     486,
  /**/

-- 
       [Autumn changed into Winter ... Winter changed into Spring ...  Spring
       changed back into Autumn and Autumn gave Winter and Spring a miss and
       went straight on into Summer ...  Until one day ...]
                 "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/202003302052.02UKq25K017467%40masaka.moolenaar.net.

Raspunde prin e-mail lui