Mirror of the Vim source from https://github.com/vim/vim
Révision | 6556318822885aa89ffe7af3d4507dffa88c7a37 (tree) |
---|---|
l'heure | 2020-02-20 06:45:03 |
Auteur | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
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
@@ -65,6 +65,8 @@ | ||
65 | 65 | assert_equal('xxxyyy', s:appendToMe) |
66 | 66 | s:addToMe += 222 |
67 | 67 | assert_equal(333, s:addToMe) |
68 | + s:newVar = 'new' | |
69 | + assert_equal('new', s:newVar) | |
68 | 70 | enddef |
69 | 71 | |
70 | 72 | func Test_assignment_failure() |
@@ -739,6 +739,8 @@ | ||
739 | 739 | static int included_patches[] = |
740 | 740 | { /* Add new patch number below this line */ |
741 | 741 | /**/ |
742 | + 285, | |
743 | +/**/ | |
742 | 744 | 284, |
743 | 745 | /**/ |
744 | 746 | 283, |
@@ -3284,10 +3284,9 @@ | ||
3284 | 3284 | } |
3285 | 3285 | } |
3286 | 3286 | } |
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) | |
3291 | 3290 | { |
3292 | 3291 | dest = dest_script; |
3293 | 3292 | if (is_decl) |
@@ -3566,7 +3565,7 @@ | ||
3566 | 3565 | idx = get_script_item_idx(sid, rawname, TRUE); |
3567 | 3566 | // TODO: specific type |
3568 | 3567 | if (idx < 0) |
3569 | - generate_OLDSCRIPT(cctx, ISN_STORES, rawname, sid, &t_any); | |
3568 | + generate_OLDSCRIPT(cctx, ISN_STORES, name, sid, &t_any); | |
3570 | 3569 | else |
3571 | 3570 | generate_VIM9SCRIPT(cctx, ISN_STORESCRIPT, |
3572 | 3571 | sid, idx, &t_any); |
@@ -356,6 +356,20 @@ | ||
356 | 356 | } |
357 | 357 | |
358 | 358 | /* |
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 | +/* | |
359 | 373 | * Execute a function by "name". |
360 | 374 | * This can be a builtin function, user function or a funcref. |
361 | 375 | */ |
@@ -556,6 +570,7 @@ | ||
556 | 570 | iptr->isn_arg.loadstore.ls_sid); |
557 | 571 | char_u *name = iptr->isn_arg.loadstore.ls_name; |
558 | 572 | dictitem_T *di = find_var_in_ht(ht, 0, name, TRUE); |
573 | + | |
559 | 574 | if (di == NULL) |
560 | 575 | { |
561 | 576 | semsg(_(e_undefvar), name); |
@@ -574,10 +589,9 @@ | ||
574 | 589 | // load g: variable |
575 | 590 | case ISN_LOADG: |
576 | 591 | { |
577 | - dictitem_T *di; | |
592 | + dictitem_T *di = find_var_in_ht(get_globvar_ht(), 0, | |
593 | + iptr->isn_arg.string, TRUE); | |
578 | 594 | |
579 | - di = find_var_in_ht(get_globvar_ht(), 0, | |
580 | - iptr->isn_arg.string, TRUE); | |
581 | 595 | if (di == NULL) |
582 | 596 | { |
583 | 597 | semsg(_("E121: Undefined variable: g:%s"), |
@@ -617,12 +631,8 @@ | ||
617 | 631 | |
618 | 632 | if (ga_grow(&ectx.ec_stack, 1) == FAIL) |
619 | 633 | 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); | |
626 | 636 | *STACK_TV_BOT(0) = optval; |
627 | 637 | ++ectx.ec_stack.ga_len; |
628 | 638 | } |
@@ -653,16 +663,16 @@ | ||
653 | 663 | hashtab_T *ht = &SCRIPT_VARS( |
654 | 664 | iptr->isn_arg.loadstore.ls_sid); |
655 | 665 | 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); | |
657 | 667 | |
668 | + --ectx.ec_stack.ga_len; | |
658 | 669 | if (di == NULL) |
670 | + store_var(iptr->isn_arg.string, STACK_TV_BOT(0)); | |
671 | + else | |
659 | 672 | { |
660 | - semsg(_(e_undefvar), name); | |
661 | - goto failed; | |
673 | + clear_tv(&di->di_tv); | |
674 | + di->di_tv = *STACK_TV_BOT(0); | |
662 | 675 | } |
663 | - --ectx.ec_stack.ga_len; | |
664 | - clear_tv(&di->di_tv); | |
665 | - di->di_tv = *STACK_TV_BOT(0); | |
666 | 676 | } |
667 | 677 | break; |
668 | 678 |
@@ -750,14 +760,7 @@ | ||
750 | 760 | di = find_var_in_ht(get_globvar_ht(), 0, |
751 | 761 | iptr->isn_arg.string + 2, TRUE); |
752 | 762 | 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)); | |
761 | 764 | else |
762 | 765 | { |
763 | 766 | clear_tv(&di->di_tv); |
@@ -1723,7 +1726,7 @@ | ||
1723 | 1726 | scriptitem_T *si = SCRIPT_ITEM( |
1724 | 1727 | iptr->isn_arg.loadstore.ls_sid); |
1725 | 1728 | |
1726 | - smsg("%4d STORES s:%s in %s", current, | |
1729 | + smsg("%4d STORES %s in %s", current, | |
1727 | 1730 | iptr->isn_arg.string, si->sn_name); |
1728 | 1731 | } |
1729 | 1732 | break; |