comparison src/vim9execute.c @ 19455:655631882288 v8.2.0285

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.
author Bram Moolenaar <Bram@vim.org>
date Wed, 19 Feb 2020 22:45:03 +0100
parents f8408ba21982
children 423b27246383
comparison
equal deleted inserted replaced
19454:f83a66aaea44 19455:655631882288
354 } 354 }
355 return OK; 355 return OK;
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 * Execute a function by "name". 373 * Execute a function by "name".
360 * This can be a builtin function, user function or a funcref. 374 * This can be a builtin function, user function or a funcref.
361 */ 375 */
362 static int 376 static int
363 call_eval_func(char_u *name, int argcount, ectx_T *ectx) 377 call_eval_func(char_u *name, int argcount, ectx_T *ectx)
554 { 568 {
555 hashtab_T *ht = &SCRIPT_VARS( 569 hashtab_T *ht = &SCRIPT_VARS(
556 iptr->isn_arg.loadstore.ls_sid); 570 iptr->isn_arg.loadstore.ls_sid);
557 char_u *name = iptr->isn_arg.loadstore.ls_name; 571 char_u *name = iptr->isn_arg.loadstore.ls_name;
558 dictitem_T *di = find_var_in_ht(ht, 0, name, TRUE); 572 dictitem_T *di = find_var_in_ht(ht, 0, name, TRUE);
573
559 if (di == NULL) 574 if (di == NULL)
560 { 575 {
561 semsg(_(e_undefvar), name); 576 semsg(_(e_undefvar), name);
562 goto failed; 577 goto failed;
563 } 578 }
572 break; 587 break;
573 588
574 // load g: variable 589 // load g: variable
575 case ISN_LOADG: 590 case ISN_LOADG:
576 { 591 {
577 dictitem_T *di; 592 dictitem_T *di = find_var_in_ht(get_globvar_ht(), 0,
578
579 di = find_var_in_ht(get_globvar_ht(), 0,
580 iptr->isn_arg.string, TRUE); 593 iptr->isn_arg.string, TRUE);
594
581 if (di == NULL) 595 if (di == NULL)
582 { 596 {
583 semsg(_("E121: Undefined variable: g:%s"), 597 semsg(_("E121: Undefined variable: g:%s"),
584 iptr->isn_arg.string); 598 iptr->isn_arg.string);
585 goto failed; 599 goto failed;
615 typval_T optval; 629 typval_T optval;
616 char_u *name = iptr->isn_arg.string; 630 char_u *name = iptr->isn_arg.string;
617 631
618 if (ga_grow(&ectx.ec_stack, 1) == FAIL) 632 if (ga_grow(&ectx.ec_stack, 1) == FAIL)
619 goto failed; 633 goto failed;
620 if (get_env_tv(&name, &optval, TRUE) == FAIL) 634 // name is always valid, checked when compiling
621 { 635 (void)get_env_tv(&name, &optval, TRUE);
622 semsg(_("E1060: Invalid environment variable name: %s"),
623 iptr->isn_arg.string);
624 goto failed;
625 }
626 *STACK_TV_BOT(0) = optval; 636 *STACK_TV_BOT(0) = optval;
627 ++ectx.ec_stack.ga_len; 637 ++ectx.ec_stack.ga_len;
628 } 638 }
629 break; 639 break;
630 640
651 case ISN_STORES: 661 case ISN_STORES:
652 { 662 {
653 hashtab_T *ht = &SCRIPT_VARS( 663 hashtab_T *ht = &SCRIPT_VARS(
654 iptr->isn_arg.loadstore.ls_sid); 664 iptr->isn_arg.loadstore.ls_sid);
655 char_u *name = iptr->isn_arg.loadstore.ls_name; 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 if (di == NULL) 669 if (di == NULL)
659 { 670 store_var(iptr->isn_arg.string, STACK_TV_BOT(0));
660 semsg(_(e_undefvar), name); 671 else
661 goto failed; 672 {
662 } 673 clear_tv(&di->di_tv);
663 --ectx.ec_stack.ga_len; 674 di->di_tv = *STACK_TV_BOT(0);
664 clear_tv(&di->di_tv); 675 }
665 di->di_tv = *STACK_TV_BOT(0);
666 } 676 }
667 break; 677 break;
668 678
669 // store script-local variable in Vim9 script 679 // store script-local variable in Vim9 script
670 case ISN_STORESCRIPT: 680 case ISN_STORESCRIPT:
748 758
749 --ectx.ec_stack.ga_len; 759 --ectx.ec_stack.ga_len;
750 di = find_var_in_ht(get_globvar_ht(), 0, 760 di = find_var_in_ht(get_globvar_ht(), 0,
751 iptr->isn_arg.string + 2, TRUE); 761 iptr->isn_arg.string + 2, TRUE);
752 if (di == NULL) 762 if (di == NULL)
753 { 763 store_var(iptr->isn_arg.string, STACK_TV_BOT(0));
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 }
761 else 764 else
762 { 765 {
763 clear_tv(&di->di_tv); 766 clear_tv(&di->di_tv);
764 di->di_tv = *STACK_TV_BOT(0); 767 di->di_tv = *STACK_TV_BOT(0);
765 } 768 }
1721 case ISN_STORES: 1724 case ISN_STORES:
1722 { 1725 {
1723 scriptitem_T *si = SCRIPT_ITEM( 1726 scriptitem_T *si = SCRIPT_ITEM(
1724 iptr->isn_arg.loadstore.ls_sid); 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 iptr->isn_arg.string, si->sn_name); 1730 iptr->isn_arg.string, si->sn_name);
1728 } 1731 }
1729 break; 1732 break;
1730 case ISN_STORESCRIPT: 1733 case ISN_STORESCRIPT:
1731 { 1734 {