• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révision6556318822885aa89ffe7af3d4507dffa88c7a37 (tree)
l'heure2020-02-20 06:45:03
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.2.0285: unused error message; cannot create s:var

Commit: https://github.com/vim/vim/commit/0bbf722aaaa75b1bbe87ef6afc44c5fff8e3893b
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 19 22:31:48 2020 +0100

patch 8.2.0285: unused error message; cannot create s:var
Problem: Unused error message. Cannot create s:var.
Solution: Remove the error message. Make assignment to s:var work.

Change Summary

Modification

diff -r f83a66aaea44 -r 655631882288 src/testdir/test_vim9_script.vim
--- a/src/testdir/test_vim9_script.vim Wed Feb 19 21:15:04 2020 +0100
+++ b/src/testdir/test_vim9_script.vim Wed Feb 19 22:45:03 2020 +0100
@@ -65,6 +65,8 @@
6565 assert_equal('xxxyyy', s:appendToMe)
6666 s:addToMe += 222
6767 assert_equal(333, s:addToMe)
68+ s:newVar = 'new'
69+ assert_equal('new', s:newVar)
6870 enddef
6971
7072 func Test_assignment_failure()
diff -r f83a66aaea44 -r 655631882288 src/version.c
--- a/src/version.c Wed Feb 19 21:15:04 2020 +0100
+++ b/src/version.c Wed Feb 19 22:45:03 2020 +0100
@@ -739,6 +739,8 @@
739739 static int included_patches[] =
740740 { /* Add new patch number below this line */
741741 /**/
742+ 285,
743+/**/
742744 284,
743745 /**/
744746 283,
diff -r f83a66aaea44 -r 655631882288 src/vim9compile.c
--- a/src/vim9compile.c Wed Feb 19 21:15:04 2020 +0100
+++ b/src/vim9compile.c Wed Feb 19 22:45:03 2020 +0100
@@ -3284,10 +3284,9 @@
32843284 }
32853285 }
32863286 }
3287- else if ((STRNCMP(arg, "s:", 2) == 0
3288- ? lookup_script(arg + 2, varlen - 2)
3289- : lookup_script(arg, varlen)) == OK
3290- || find_imported(arg, varlen, cctx) != NULL)
3287+ else if (STRNCMP(arg, "s:", 2) == 0
3288+ || lookup_script(arg, varlen) == OK
3289+ || find_imported(arg, varlen, cctx) != NULL)
32913290 {
32923291 dest = dest_script;
32933292 if (is_decl)
@@ -3566,7 +3565,7 @@
35663565 idx = get_script_item_idx(sid, rawname, TRUE);
35673566 // TODO: specific type
35683567 if (idx < 0)
3569- generate_OLDSCRIPT(cctx, ISN_STORES, rawname, sid, &t_any);
3568+ generate_OLDSCRIPT(cctx, ISN_STORES, name, sid, &t_any);
35703569 else
35713570 generate_VIM9SCRIPT(cctx, ISN_STORESCRIPT,
35723571 sid, idx, &t_any);
diff -r f83a66aaea44 -r 655631882288 src/vim9execute.c
--- a/src/vim9execute.c Wed Feb 19 21:15:04 2020 +0100
+++ b/src/vim9execute.c Wed Feb 19 22:45:03 2020 +0100
@@ -356,6 +356,20 @@
356356 }
357357
358358 /*
359+ * Store "tv" in variable "name".
360+ * This is for s: and g: variables.
361+ */
362+ static void
363+store_var(char_u *name, typval_T *tv)
364+{
365+ funccal_entry_T entry;
366+
367+ save_funccal(&entry);
368+ set_var_const(name, NULL, tv, FALSE, 0);
369+ restore_funccal();
370+}
371+
372+/*
359373 * Execute a function by "name".
360374 * This can be a builtin function, user function or a funcref.
361375 */
@@ -556,6 +570,7 @@
556570 iptr->isn_arg.loadstore.ls_sid);
557571 char_u *name = iptr->isn_arg.loadstore.ls_name;
558572 dictitem_T *di = find_var_in_ht(ht, 0, name, TRUE);
573+
559574 if (di == NULL)
560575 {
561576 semsg(_(e_undefvar), name);
@@ -574,10 +589,9 @@
574589 // load g: variable
575590 case ISN_LOADG:
576591 {
577- dictitem_T *di;
592+ dictitem_T *di = find_var_in_ht(get_globvar_ht(), 0,
593+ iptr->isn_arg.string, TRUE);
578594
579- di = find_var_in_ht(get_globvar_ht(), 0,
580- iptr->isn_arg.string, TRUE);
581595 if (di == NULL)
582596 {
583597 semsg(_("E121: Undefined variable: g:%s"),
@@ -617,12 +631,8 @@
617631
618632 if (ga_grow(&ectx.ec_stack, 1) == FAIL)
619633 goto failed;
620- if (get_env_tv(&name, &optval, TRUE) == FAIL)
621- {
622- semsg(_("E1060: Invalid environment variable name: %s"),
623- iptr->isn_arg.string);
624- goto failed;
625- }
634+ // name is always valid, checked when compiling
635+ (void)get_env_tv(&name, &optval, TRUE);
626636 *STACK_TV_BOT(0) = optval;
627637 ++ectx.ec_stack.ga_len;
628638 }
@@ -653,16 +663,16 @@
653663 hashtab_T *ht = &SCRIPT_VARS(
654664 iptr->isn_arg.loadstore.ls_sid);
655665 char_u *name = iptr->isn_arg.loadstore.ls_name;
656- dictitem_T *di = find_var_in_ht(ht, 0, name, TRUE);
666+ dictitem_T *di = find_var_in_ht(ht, 0, name + 2, TRUE);
657667
668+ --ectx.ec_stack.ga_len;
658669 if (di == NULL)
670+ store_var(iptr->isn_arg.string, STACK_TV_BOT(0));
671+ else
659672 {
660- semsg(_(e_undefvar), name);
661- goto failed;
673+ clear_tv(&di->di_tv);
674+ di->di_tv = *STACK_TV_BOT(0);
662675 }
663- --ectx.ec_stack.ga_len;
664- clear_tv(&di->di_tv);
665- di->di_tv = *STACK_TV_BOT(0);
666676 }
667677 break;
668678
@@ -750,14 +760,7 @@
750760 di = find_var_in_ht(get_globvar_ht(), 0,
751761 iptr->isn_arg.string + 2, TRUE);
752762 if (di == NULL)
753- {
754- funccal_entry_T entry;
755-
756- save_funccal(&entry);
757- set_var_const(iptr->isn_arg.string, NULL,
758- STACK_TV_BOT(0), FALSE, 0);
759- restore_funccal();
760- }
763+ store_var(iptr->isn_arg.string, STACK_TV_BOT(0));
761764 else
762765 {
763766 clear_tv(&di->di_tv);
@@ -1723,7 +1726,7 @@
17231726 scriptitem_T *si = SCRIPT_ITEM(
17241727 iptr->isn_arg.loadstore.ls_sid);
17251728
1726- smsg("%4d STORES s:%s in %s", current,
1729+ smsg("%4d STORES %s in %s", current,
17271730 iptr->isn_arg.string, si->sn_name);
17281731 }
17291732 break;
Afficher sur ancien navigateur de dépôt.