comparison src/vim9compile.c @ 24956:d0b6a8d82cef v8.2.3015

patch 8.2.3015: Vim9: Assigning to @# requires a string Commit: https://github.com/vim/vim/commit/74f4a965bc6e2a9c41cce2f644e861168702922f Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 17 21:03:07 2021 +0200 patch 8.2.3015: Vim9: Assigning to @# requires a string Problem: Vim9: Assigning to @# requires a string. (Naohiro Ono) Solution: Accent a number or a string. (closes https://github.com/vim/vim/issues/8396)
author Bram Moolenaar <Bram@vim.org>
date Thu, 17 Jun 2021 21:15:03 +0200
parents 5c418c774f95
children 71b1e2ef0069
comparison
equal deleted inserted replaced
24955:04373d30ea32 24956:d0b6a8d82cef
5850 { 5850 {
5851 emsg_invreg(name[1]); 5851 emsg_invreg(name[1]);
5852 return FAIL; 5852 return FAIL;
5853 } 5853 }
5854 *dest = dest_reg; 5854 *dest = dest_reg;
5855 *type = &t_string; 5855 *type = name[1] == '#' ? &t_number_or_string : &t_string;
5856 } 5856 }
5857 else if (STRNCMP(name, "g:", 2) == 0) 5857 else if (STRNCMP(name, "g:", 2) == 0)
5858 { 5858 {
5859 *dest = dest_global; 5859 *dest = dest_global;
5860 } 5860 }
5925 // include t: with the name, easier to execute that way 5925 // include t: with the name, easier to execute that way
5926 return generate_STORE(cctx, ISN_STORET, 0, name); 5926 return generate_STORE(cctx, ISN_STORET, 0, name);
5927 case dest_env: 5927 case dest_env:
5928 return generate_STORE(cctx, ISN_STOREENV, 0, name + 1); 5928 return generate_STORE(cctx, ISN_STOREENV, 0, name + 1);
5929 case dest_reg: 5929 case dest_reg:
5930 return generate_STORE(cctx, ISN_STOREREG, name[1], NULL); 5930 return generate_STORE(cctx, ISN_STOREREG,
5931 name[1] == '@' ? '"' : name[1], NULL);
5931 case dest_vimvar: 5932 case dest_vimvar:
5932 return generate_STORE(cctx, ISN_STOREV, vimvaridx, NULL); 5933 return generate_STORE(cctx, ISN_STOREV, vimvaridx, NULL);
5933 case dest_script: 5934 case dest_script:
5934 if (scriptvar_idx < 0) 5935 if (scriptvar_idx < 0)
5935 // "s:" may be included in the name. 5936 // "s:" may be included in the name.
6841 if (need_type(rhs_type, use_type, -1, 0, cctx, 6842 if (need_type(rhs_type, use_type, -1, 0, cctx,
6842 FALSE, is_const) == FAIL) 6843 FALSE, is_const) == FAIL)
6843 goto theend; 6844 goto theend;
6844 } 6845 }
6845 } 6846 }
6846 else if (*p != '=' && need_type(rhs_type, lhs.lhs_member_type, 6847 else
6848 {
6849 type_T *lhs_type = lhs.lhs_member_type;
6850
6851 // Special case: assigning to @# can use a number or a
6852 // string.
6853 if (lhs_type == &t_number_or_string
6854 && rhs_type->tt_type == VAR_NUMBER)
6855 lhs_type = &t_number;
6856 if (*p != '=' && need_type(rhs_type, lhs_type,
6847 -1, 0, cctx, FALSE, FALSE) == FAIL) 6857 -1, 0, cctx, FALSE, FALSE) == FAIL)
6848 goto theend; 6858 goto theend;
6859 }
6849 } 6860 }
6850 else if (cmdidx == CMD_final) 6861 else if (cmdidx == CMD_final)
6851 { 6862 {
6852 emsg(_(e_final_requires_a_value)); 6863 emsg(_(e_final_requires_a_value));
6853 goto theend; 6864 goto theend;