Mercurial > vim
comparison src/evalvars.c @ 20953:6b4b887a12f0 v8.2.1028
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Commit: https://github.com/vim/vim/commit/e55b1c098d9dc04c960e6575bb554b5130af8989
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 21 15:52:59 2020 +0200
patch 8.2.1028: Vim9: no error for declaring buffer, window, etc. variable
Problem: Vim9: no error for declaring buffer, window, etc. variable.
Solution: Give an error. Unify the error messages.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 21 Jun 2020 16:00:04 +0200 |
parents | 0653b9b72091 |
children | 7ee565134d4a |
comparison
equal
deleted
inserted
replaced
20952:c297dfafbc7d | 20953:6b4b887a12f0 |
---|---|
1202 if (flags & LET_IS_CONST) | 1202 if (flags & LET_IS_CONST) |
1203 { | 1203 { |
1204 emsg(_("E996: Cannot lock an environment variable")); | 1204 emsg(_("E996: Cannot lock an environment variable")); |
1205 return NULL; | 1205 return NULL; |
1206 } | 1206 } |
1207 if (current_sctx.sc_version == SCRIPT_VERSION_VIM9 | |
1208 && (flags & LET_NO_COMMAND) == 0) | |
1209 { | |
1210 vim9_declare_error(arg); | |
1211 return NULL; | |
1212 } | |
1213 | |
1207 // Find the end of the name. | 1214 // Find the end of the name. |
1208 ++arg; | 1215 ++arg; |
1209 name = arg; | 1216 name = arg; |
1210 len = get_env_len(&arg); | 1217 len = get_env_len(&arg); |
1211 if (len == 0) | 1218 if (len == 0) |
2862 if (ht == NULL || *varname == NUL) | 2869 if (ht == NULL || *varname == NUL) |
2863 { | 2870 { |
2864 semsg(_(e_illvar), name); | 2871 semsg(_(e_illvar), name); |
2865 return; | 2872 return; |
2866 } | 2873 } |
2874 is_script_local = ht == get_script_local_ht(); | |
2875 | |
2867 if (current_sctx.sc_version == SCRIPT_VERSION_VIM9 | 2876 if (current_sctx.sc_version == SCRIPT_VERSION_VIM9 |
2868 && ht == &globvarht | 2877 && !is_script_local |
2869 && (flags & LET_NO_COMMAND) == 0) | 2878 && (flags & LET_NO_COMMAND) == 0 |
2870 { | 2879 && name[1] == ':') |
2871 semsg(_(e_declare_global), name); | 2880 { |
2881 vim9_declare_error(name); | |
2872 return; | 2882 return; |
2873 } | 2883 } |
2874 | |
2875 is_script_local = ht == get_script_local_ht(); | |
2876 | 2884 |
2877 di = find_var_in_ht(ht, 0, varname, TRUE); | 2885 di = find_var_in_ht(ht, 0, varname, TRUE); |
2878 | 2886 |
2879 // Search in parent scope which is possible to reference from lambda | 2887 // Search in parent scope which is possible to reference from lambda |
2880 if (di == NULL) | 2888 if (di == NULL) |