comparison src/vim9compile.c @ 24377:f9f8cceaece3 v8.2.2729

patch 8.2.2729: Vim9: wrong error message for referring to legacy script var Commit: https://github.com/vim/vim/commit/643ce6c0c694667a2afd24bb39d8e9d36d94d7a9 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Apr 6 21:17:27 2021 +0200 patch 8.2.2729: Vim9: wrong error message for referring to legacy script var Problem: Vim9: wrong error message for referring to legacy script variable. Solution: Do allow referring to a variable in legacy script without "s:" if it exists at compile time. (closes #8076)
author Bram Moolenaar <Bram@vim.org>
date Tue, 06 Apr 2021 21:30:04 +0200
parents 1a145eb83a28
children 8d5e4b50c2e1
comparison
equal deleted inserted replaced
24376:d9b9f9e0c7ee 24377:f9f8cceaece3
5706 return generate_STORE(cctx, ISN_STOREREG, name[1], NULL); 5706 return generate_STORE(cctx, ISN_STOREREG, name[1], NULL);
5707 case dest_vimvar: 5707 case dest_vimvar:
5708 return generate_STORE(cctx, ISN_STOREV, vimvaridx, NULL); 5708 return generate_STORE(cctx, ISN_STOREV, vimvaridx, NULL);
5709 case dest_script: 5709 case dest_script:
5710 if (scriptvar_idx < 0) 5710 if (scriptvar_idx < 0)
5711 { 5711 // "s:" may be included in the name.
5712 char_u *name_s = name; 5712 return generate_OLDSCRIPT(cctx, ISN_STORES, name,
5713 int r;
5714
5715 // "s:" is included in the name.
5716 r = generate_OLDSCRIPT(cctx, ISN_STORES, name_s,
5717 scriptvar_sid, type); 5713 scriptvar_sid, type);
5718 if (name_s != name)
5719 vim_free(name_s);
5720 return r;
5721 }
5722 return generate_VIM9SCRIPT(cctx, ISN_STORESCRIPT, 5714 return generate_VIM9SCRIPT(cctx, ISN_STORESCRIPT,
5723 scriptvar_sid, scriptvar_idx, type); 5715 scriptvar_sid, scriptvar_idx, type);
5724 case dest_local: 5716 case dest_local:
5725 case dest_expr: 5717 case dest_expr:
5726 // cannot happen 5718 // cannot happen
5852 && STRNCMP(var_start, "s:", 2) == 0; 5844 && STRNCMP(var_start, "s:", 2) == 0;
5853 int script_var = (script_namespace 5845 int script_var = (script_namespace
5854 ? script_var_exists(var_start + 2, lhs->lhs_varlen - 2, 5846 ? script_var_exists(var_start + 2, lhs->lhs_varlen - 2,
5855 FALSE, cctx) 5847 FALSE, cctx)
5856 : script_var_exists(var_start, lhs->lhs_varlen, 5848 : script_var_exists(var_start, lhs->lhs_varlen,
5857 TRUE, cctx)) == OK; 5849 FALSE, cctx)) == OK;
5858 imported_T *import = 5850 imported_T *import =
5859 find_imported(var_start, lhs->lhs_varlen, cctx); 5851 find_imported(var_start, lhs->lhs_varlen, cctx);
5860 5852
5861 if (script_namespace || script_var || import != NULL) 5853 if (script_namespace || script_var || import != NULL)
5862 { 5854 {