Patch 8.2.0764
Problem:    Vim9: assigning to option not fully tested.
Solution:   Add more test cases. Allow using any type for assignment.
Files:      src/vim9compile.c, src/vim9execute.c,
            src/testdir/test_vim9_script.vim


*** ../vim-8.2.0763/src/vim9compile.c   2020-05-14 22:41:10.229637563 +0200
--- src/vim9compile.c   2020-05-15 23:26:26.476550213 +0200
***************
*** 3490,3496 ****
            type_T      **typep;
  
            // list index: list[123]
!           // list member: dict[key]
            // TODO: blob index
            // TODO: more arguments
            // TODO: recognize list or dict at runtime
--- 3490,3496 ----
            type_T      **typep;
  
            // list index: list[123]
!           // dict member: dict[key]
            // TODO: blob index
            // TODO: more arguments
            // TODO: recognize list or dict at runtime
***************
*** 4999,5006 ****
                        goto theend;
                }
            }
!           else if (*p != '=' && check_type(member_type, stacktype, TRUE)
!                                                                      == FAIL)
                goto theend;
        }
      }
--- 4999,5006 ----
                        goto theend;
                }
            }
!           else if (*p != '=' && need_type(stacktype, member_type, -1,
!                                                                cctx) == FAIL)
                goto theend;
        }
      }
*** ../vim-8.2.0763/src/vim9execute.c   2020-05-15 21:44:14.400495565 +0200
--- src/vim9execute.c   2020-05-15 23:32:55.347465694 +0200
***************
*** 1164,1176 ****
                        if (s == NULL)
                            s = (char_u *)"";
                    }
-                   else if (tv->v_type == VAR_NUMBER)
-                       n = tv->vval.v_number;
                    else
!                   {
!                       emsg(_("E1051: Expected string or number"));
!                       goto failed;
!                   }
                    msg = set_option_value(iptr->isn_arg.storeopt.so_name,
                                        n, s, iptr->isn_arg.storeopt.so_flags);
                    if (msg != NULL)
--- 1164,1172 ----
                        if (s == NULL)
                            s = (char_u *)"";
                    }
                    else
!                       // must be VAR_NUMBER, CHECKTYPE makes sure
!                       n = tv->vval.v_number;
                    msg = set_option_value(iptr->isn_arg.storeopt.so_name,
                                        n, s, iptr->isn_arg.storeopt.so_flags);
                    if (msg != NULL)
*** ../vim-8.2.0763/src/testdir/test_vim9_script.vim    2020-05-15 
18:17:24.590759529 +0200
--- src/testdir/test_vim9_script.vim    2020-05-15 23:34:27.519195667 +0200
***************
*** 14,19 ****
--- 14,21 ----
  let g:existing = 'yes'
  let g:inc_counter = 1
  let $SOME_ENV_VAR = 'some'
+ let g:alist = [7]
+ let g:astring = 'text'
  
  def Test_assignment()
    let bool1: bool = true
***************
*** 95,101 ****
--- 97,108 ----
    assert_equal(2, &ts)
    call CheckDefFailure(['&notex += 3'], 'E113:')
    call CheckDefFailure(['&ts ..= "xxx"'], 'E1019:')
+   call CheckDefFailure(['&ts = [7]'], 'E1013:')
+   call CheckDefExecFailure(['&ts = g:alist'], 'E1029: Expected number but got 
list')
+   call CheckDefFailure(['&ts = "xx"'], 'E1013:')
+   call CheckDefExecFailure(['&ts = g:astring'], 'E1029: Expected number but 
got string')
    call CheckDefFailure(['&path += 3'], 'E1013:')
+   call CheckDefExecFailure(['&bs = "asdf"'], 'E474:')
    # test freeing ISN_STOREOPT
    call CheckDefFailure(['&ts = 3', 'let asdf'], 'E1022:')
    &ts = 8
*** ../vim-8.2.0763/src/version.c       2020-05-15 22:46:40.759917714 +0200
--- src/version.c       2020-05-15 23:34:59.359101655 +0200
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     764,
  /**/

-- 
Contrary to popular belief, Unix is user friendly.
It just happens to be selective about who it makes friends with.
                                               -- Dave Parnas

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202005152140.04FLepRE030852%40masaka.moolenaar.net.

Raspunde prin e-mail lui