From e03f23189d765ade07b21d2f50c047f84741a133 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Nov 2022 06:31:00 +0800 Subject: vim-patch:8.2.1274: Vim9: no error for missing white space at script level Problem: Vim9: no error for missing white space in assignment at script level. Solution: Check for white space. (closes vim/vim#6495) https://github.com/vim/vim/commit/63be3d4ba01d565e645d8bf7f4dc900fc9011534 Cherry-pick Test_let_errors() change from patch 8.2.0633. Co-authored-by: Bram Moolenaar --- src/nvim/eval.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 1200ba20ba..b93367381d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6694,7 +6694,8 @@ const char *find_name_end(const char *arg, const char **expr_start, const char * for (p = arg; *p != NUL && (eval_isnamec(*p) || *p == '{' - || ((flags & FNE_INCL_BR) && (*p == '[' || *p == '.')) + || ((flags & FNE_INCL_BR) && (*p == '[' + || (*p == '.' && eval_isnamec1(p[1])))) || mb_nest != 0 || br_nest != 0); MB_PTR_ADV(p)) { if (*p == '\'') { -- cgit From 1f0bf65ad6ce6df3eedfb013cf9b95aed2a90781 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Nov 2022 06:35:34 +0800 Subject: vim-patch:8.2.1306: checking for first character of dict key is inconsistent Problem: Checking for first character of dict key is inconsistent. Solution: Add eval_isdictc(). (closes vim/vim#6546) https://github.com/vim/vim/commit/b13ab99908097d54e21ab5adad22f4ad2a8ec688 Omit handle_subscript() change: only affects Vim9 script. Co-authored-by: Bram Moolenaar --- src/nvim/eval.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b93367381d..4b545c0dec 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -3418,7 +3418,7 @@ static int eval_index(char **arg, typval_T *rettv, int evaluate, int verbose) if (**arg == '.') { // dict.name key = *arg + 1; - for (len = 0; ASCII_ISALNUM(key[len]) || key[len] == '_'; len++) {} + for (len = 0; eval_isdictc(key[len]); len++) {} if (len == 0) { return FAIL; } @@ -6695,7 +6695,7 @@ const char *find_name_end(const char *arg, const char **expr_start, const char * && (eval_isnamec(*p) || *p == '{' || ((flags & FNE_INCL_BR) && (*p == '[' - || (*p == '.' && eval_isnamec1(p[1])))) + || (*p == '.' && eval_isdictc(p[1])))) || mb_nest != 0 || br_nest != 0); MB_PTR_ADV(p)) { if (*p == '\'') { @@ -6808,18 +6808,25 @@ static char *make_expanded_name(const char *in_start, char *expr_start, char *ex /// @return true if character "c" can be used in a variable or function name. /// Does not include '{' or '}' for magic braces. -int eval_isnamec(int c) +bool eval_isnamec(int c) { return ASCII_ISALNUM(c) || c == '_' || c == ':' || c == AUTOLOAD_CHAR; } /// @return true if character "c" can be used as the first character in a /// variable or function name (excluding '{' and '}'). -int eval_isnamec1(int c) +bool eval_isnamec1(int c) { return ASCII_ISALPHA(c) || c == '_'; } +/// @return true if character "c" can be used as the first character of a +/// dictionary key. +bool eval_isdictc(int c) +{ + return ASCII_ISALNUM(c) || c == '_'; +} + /// Get typval_T v: variable value. typval_T *get_vim_var_tv(int idx) { -- cgit From a208a8b10eced35916cc1093453f4485bdbccb7a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Nov 2022 06:46:30 +0800 Subject: vim-patch:8.2.2722: Vim9: crash when using LHS with double index Problem: Vim9: crash when using LHS with double index. Solution: Handle lhs_dest which is "dest_expr". (closes vim/vim#8068) Fix confusing error message for missing dict item. https://github.com/vim/vim/commit/b9c0cd897ab4ad54f514187e89719c0241393f8b Co-authored-by: Bram Moolenaar --- src/nvim/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 4b545c0dec..62e006fd57 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1757,7 +1757,7 @@ void set_var_lval(lval_T *lp, char *endp, typval_T *rettv, int copy, const bool // Assign to a List or Dictionary item. if (lp->ll_newkey != NULL) { if (op != NULL && *op != '=') { - semsg(_(e_letwrong), op); + semsg(_(e_dictkey), lp->ll_newkey); return; } -- cgit From 7d7208a88b2bb078c9c2727e93ef390f2a564027 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 6 Nov 2022 06:47:54 +0800 Subject: vim-patch:8.2.3016: confusing error when expression is followed by comma Problem: Confusing error when expression is followed by comma. Solution: Give a different error for trailing text. (closes vim/vim#8395) https://github.com/vim/vim/commit/fae55a9cb0838e4c2e634e55a3468af4a75fbdf2 Omit test_eval_stuff.vim and test_viminfo.vim: changes tests are N/A. Co-authored-by: Bram Moolenaar --- src/nvim/eval.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 62e006fd57..465d76de69 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2277,10 +2277,15 @@ int eval0(char *arg, typval_T *rettv, char **nextcmd, int evaluate) char *p; const int did_emsg_before = did_emsg; const int called_emsg_before = called_emsg; + bool end_error = false; p = skipwhite(arg); ret = eval1(&p, rettv, evaluate); - if (ret == FAIL || !ends_excmd(*p)) { + + if (ret != FAIL) { + end_error = !ends_excmd(*p); + } + if (ret == FAIL || end_error) { if (ret != FAIL) { tv_clear(rettv); } @@ -2290,7 +2295,11 @@ int eval0(char *arg, typval_T *rettv, char **nextcmd, int evaluate) // Also check called_emsg for when using assert_fails(). if (!aborting() && did_emsg == did_emsg_before && called_emsg == called_emsg_before) { - semsg(_(e_invexpr2), arg); + if (end_error) { + semsg(_(e_trailing_arg), p); + } else { + semsg(_(e_invexpr2), arg); + } } ret = FAIL; } -- cgit