diff options
author | Bram Moolenaar <Bram@vim.org> | 2023-01-30 21:12:34 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-30 21:12:34 +0000 |
commit | ce93d162da8de2419c15b63286e2f72a8fe3bf2d (patch) | |
tree | c71709142faa5d59491146cd89733016bc93217a /src | |
parent | b8bebd0cd78679162228ee08265c9a5b3a409e1c (diff) | |
download | vim-git-ce93d162da8de2419c15b63286e2f72a8fe3bf2d.tar.gz |
patch 9.0.1266: error for space before ": type" is inconsistentv9.0.1266
Problem: Error for space before ": type" is inconsistent.
Solution: Give E1059 in more places. (closes #11868)
Diffstat (limited to 'src')
-rw-r--r-- | src/eval.c | 7 | ||||
-rw-r--r-- | src/evalvars.c | 4 | ||||
-rw-r--r-- | src/testdir/test_vim9_assign.vim | 7 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9cmds.c | 7 | ||||
-rw-r--r-- | src/vim9compile.c | 7 |
6 files changed, 29 insertions, 5 deletions
diff --git a/src/eval.c b/src/eval.c index 699f43bac..a0bbabfe3 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1093,7 +1093,7 @@ get_lval( --p; lp->ll_name_end = p; } - if (*p == ':') + if (*skipwhite(p) == ':') { char_u *tp = skipwhite(p + 1); @@ -1102,6 +1102,11 @@ get_lval( semsg(_(e_cannot_use_type_with_this_variable_str), name); return NULL; } + if (VIM_ISWHITE(*p)) + { + semsg(_(e_no_white_space_allowed_before_colon_str), p); + return NULL; + } if (tp == p + 1 && !quiet) { semsg(_(e_white_space_required_after_str_str), ":", p); diff --git a/src/evalvars.c b/src/evalvars.c index 68df1cb52..066543669 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -1363,8 +1363,8 @@ skip_var_one(char_u *arg, int include_type) if (include_type && vim9) { - if (*end == ':') - end = skip_type(skipwhite(end + 1), FALSE); + if (*skipwhite(end) == ':') + end = skip_type(skipwhite(skipwhite(end) + 1), FALSE); } return end; } diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim index f016ae3f7..4f4e58e06 100644 --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -360,6 +360,13 @@ def Test_null_values() v9.CheckDefAndScriptSuccess(lines) enddef +def Test_type_with_extra_white() + var lines =<< trim END + const x : number = 3 + END + v9.CheckDefExecAndScriptFailure(lines, 'E1059') +enddef + def Test_keep_type_after_assigning_null() var lines =<< trim END var b: blob diff --git a/src/version.c b/src/version.c index 24a27707a..dcf223ea8 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1266, +/**/ 1265, /**/ 1264, diff --git a/src/vim9cmds.c b/src/vim9cmds.c index 69c04aec9..fb09780cb 100644 --- a/src/vim9cmds.c +++ b/src/vim9cmds.c @@ -1001,8 +1001,13 @@ compile_for(char_u *arg_start, cctx_T *cctx) name = vim_strnsave(arg, varlen); if (name == NULL) goto failed; - if (*p == ':') + if (*skipwhite(p) == ':') { + if (VIM_ISWHITE(*p)) + { + semsg(_(e_no_white_space_allowed_before_colon_str), p); + goto failed; + } p = skipwhite(p + 1); lhs_type = parse_type(&p, cctx->ctx_type_list, TRUE); } diff --git a/src/vim9compile.c b/src/vim9compile.c index 27b71f78f..a3bb411e8 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1741,11 +1741,16 @@ compile_lhs( if (lhs->lhs_dest != dest_option && lhs->lhs_dest != dest_func_option) { - if (is_decl && *var_end == ':') + if (is_decl && *skipwhite(var_end) == ':') { char_u *p; // parse optional type: "let var: type = expr" + if (VIM_ISWHITE(*var_end)) + { + semsg(_(e_no_white_space_allowed_before_colon_str), var_end); + return FAIL; + } if (!VIM_ISWHITE(var_end[1])) { semsg(_(e_white_space_required_after_str_str), ":", var_end); |