Patch 8.2.0285
Problem:    Unused error message. Cannot create s:var.
Solution:   Remove the error message. Make assignment to s:var work.
Files:      src/vim9compile.c, src/vim9execute.c,
            src/testdir/test_vim9_script.vim


*** ../vim-8.2.0284/src/vim9compile.c   2020-02-19 21:12:34.349803015 +0100
--- src/vim9compile.c   2020-02-19 22:27:19.899582604 +0100
***************
*** 3284,3293 ****
                }
            }
        }
!       else if ((STRNCMP(arg, "s:", 2) == 0
!                   ? lookup_script(arg + 2, varlen - 2)
!                   : lookup_script(arg, varlen)) == OK
!                                  || find_imported(arg, varlen, cctx) != NULL)
        {
            dest = dest_script;
            if (is_decl)
--- 3284,3292 ----
                }
            }
        }
!       else if (STRNCMP(arg, "s:", 2) == 0
!               || lookup_script(arg, varlen) == OK
!               || find_imported(arg, varlen, cctx) != NULL)
        {
            dest = dest_script;
            if (is_decl)
***************
*** 3566,3572 ****
                idx = get_script_item_idx(sid, rawname, TRUE);
                // TODO: specific type
                if (idx < 0)
!                   generate_OLDSCRIPT(cctx, ISN_STORES, rawname, sid, &t_any);
                else
                    generate_VIM9SCRIPT(cctx, ISN_STORESCRIPT,
                                                             sid, idx, &t_any);
--- 3565,3571 ----
                idx = get_script_item_idx(sid, rawname, TRUE);
                // TODO: specific type
                if (idx < 0)
!                   generate_OLDSCRIPT(cctx, ISN_STORES, name, sid, &t_any);
                else
                    generate_VIM9SCRIPT(cctx, ISN_STORESCRIPT,
                                                             sid, idx, &t_any);
*** ../vim-8.2.0284/src/vim9execute.c   2020-02-19 18:14:35.733852144 +0100
--- src/vim9execute.c   2020-02-19 22:26:48.487738342 +0100
***************
*** 356,361 ****
--- 356,375 ----
  }
  
  /*
+  * Store "tv" in variable "name".
+  * This is for s: and g: variables.
+  */
+     static void
+ store_var(char_u *name, typval_T *tv)
+ {
+     funccal_entry_T entry;
+ 
+     save_funccal(&entry);
+     set_var_const(name, NULL, tv, FALSE, 0);
+     restore_funccal();
+ }
+ 
+ /*
   * Execute a function by "name".
   * This can be a builtin function, user function or a funcref.
   */
***************
*** 556,561 ****
--- 570,576 ----
                                               iptr->isn_arg.loadstore.ls_sid);
                    char_u      *name = iptr->isn_arg.loadstore.ls_name;
                    dictitem_T  *di = find_var_in_ht(ht, 0, name, TRUE);
+ 
                    if (di == NULL)
                    {
                        semsg(_(e_undefvar), name);
***************
*** 574,583 ****
            // load g: variable
            case ISN_LOADG:
                {
!                   dictitem_T *di;
! 
!                   di = find_var_in_ht(get_globvar_ht(), 0,
                                                   iptr->isn_arg.string, TRUE);
                    if (di == NULL)
                    {
                        semsg(_("E121: Undefined variable: g:%s"),
--- 589,597 ----
            // load g: variable
            case ISN_LOADG:
                {
!                   dictitem_T *di = find_var_in_ht(get_globvar_ht(), 0,
                                                   iptr->isn_arg.string, TRUE);
+ 
                    if (di == NULL)
                    {
                        semsg(_("E121: Undefined variable: g:%s"),
***************
*** 617,628 ****
  
                    if (ga_grow(&ectx.ec_stack, 1) == FAIL)
                        goto failed;
!                   if (get_env_tv(&name, &optval, TRUE) == FAIL)
!                   {
!                       semsg(_("E1060: Invalid environment variable name: %s"),
!                                                        iptr->isn_arg.string);
!                       goto failed;
!                   }
                    *STACK_TV_BOT(0) = optval;
                    ++ectx.ec_stack.ga_len;
                }
--- 631,638 ----
  
                    if (ga_grow(&ectx.ec_stack, 1) == FAIL)
                        goto failed;
!                   // name is always valid, checked when compiling
!                   (void)get_env_tv(&name, &optval, TRUE);
                    *STACK_TV_BOT(0) = optval;
                    ++ectx.ec_stack.ga_len;
                }
***************
*** 653,668 ****
                    hashtab_T   *ht = &SCRIPT_VARS(
                                               iptr->isn_arg.loadstore.ls_sid);
                    char_u      *name = iptr->isn_arg.loadstore.ls_name;
!                   dictitem_T  *di = find_var_in_ht(ht, 0, name, TRUE);
  
                    if (di == NULL)
                    {
!                       semsg(_(e_undefvar), name);
!                       goto failed;
                    }
-                   --ectx.ec_stack.ga_len;
-                   clear_tv(&di->di_tv);
-                   di->di_tv = *STACK_TV_BOT(0);
                }
                break;
  
--- 663,678 ----
                    hashtab_T   *ht = &SCRIPT_VARS(
                                               iptr->isn_arg.loadstore.ls_sid);
                    char_u      *name = iptr->isn_arg.loadstore.ls_name;
!                   dictitem_T  *di = find_var_in_ht(ht, 0, name + 2, TRUE);
  
+                   --ectx.ec_stack.ga_len;
                    if (di == NULL)
+                       store_var(iptr->isn_arg.string, STACK_TV_BOT(0));
+                   else
                    {
!                       clear_tv(&di->di_tv);
!                       di->di_tv = *STACK_TV_BOT(0);
                    }
                }
                break;
  
***************
*** 750,763 ****
                    di = find_var_in_ht(get_globvar_ht(), 0,
                                               iptr->isn_arg.string + 2, TRUE);
                    if (di == NULL)
!                   {
!                       funccal_entry_T entry;
! 
!                       save_funccal(&entry);
!                       set_var_const(iptr->isn_arg.string, NULL,
!                                                   STACK_TV_BOT(0), FALSE, 0);
!                       restore_funccal();
!                   }
                    else
                    {
                        clear_tv(&di->di_tv);
--- 760,766 ----
                    di = find_var_in_ht(get_globvar_ht(), 0,
                                               iptr->isn_arg.string + 2, TRUE);
                    if (di == NULL)
!                       store_var(iptr->isn_arg.string, STACK_TV_BOT(0));
                    else
                    {
                        clear_tv(&di->di_tv);
***************
*** 1723,1729 ****
                    scriptitem_T *si = SCRIPT_ITEM(
                                               iptr->isn_arg.loadstore.ls_sid);
  
!                   smsg("%4d STORES s:%s in %s", current,
                                            iptr->isn_arg.string, si->sn_name);
                }
                break;
--- 1726,1732 ----
                    scriptitem_T *si = SCRIPT_ITEM(
                                               iptr->isn_arg.loadstore.ls_sid);
  
!                   smsg("%4d STORES %s in %s", current,
                                            iptr->isn_arg.string, si->sn_name);
                }
                break;
*** ../vim-8.2.0284/src/testdir/test_vim9_script.vim    2020-02-19 
20:23:07.948950048 +0100
--- src/testdir/test_vim9_script.vim    2020-02-19 22:29:22.638979241 +0100
***************
*** 65,70 ****
--- 65,72 ----
    assert_equal('xxxyyy', s:appendToMe)
    s:addToMe += 222
    assert_equal(333, s:addToMe)
+   s:newVar = 'new'
+   assert_equal('new', s:newVar)
  enddef
  
  func Test_assignment_failure()
*** ../vim-8.2.0284/src/version.c       2020-02-19 21:12:34.353802997 +0100
--- src/version.c       2020-02-19 22:26:31.071824992 +0100
***************
*** 740,741 ****
--- 740,743 ----
  {   /* Add new patch number below this line */
+ /**/
+     285,
  /**/

-- 
>From "know your smileys":
 :-F    Bucktoothed vampire with one tooth missing

 /// 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/202002192132.01JLWG26003307%40masaka.moolenaar.net.

Raspunde prin e-mail lui