Mercurial > vim
comparison src/eval.c @ 24958:21ec48d542a8 v8.2.3016
patch 8.2.3016: confusing error when expression is followed by comma
Commit: https://github.com/vim/vim/commit/fae55a9cb0838e4c2e634e55a3468af4a75fbdf2
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 17 22:08:30 2021 +0200
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 https://github.com/vim/vim/issues/8395)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 17 Jun 2021 22:15:03 +0200 |
parents | e61a2085c89b |
children | 3b8d3b383fd6 |
comparison
equal
deleted
inserted
replaced
24957:674d99f8705f | 24958:21ec48d542a8 |
---|---|
2216 int ret; | 2216 int ret; |
2217 char_u *p; | 2217 char_u *p; |
2218 int did_emsg_before = did_emsg; | 2218 int did_emsg_before = did_emsg; |
2219 int called_emsg_before = called_emsg; | 2219 int called_emsg_before = called_emsg; |
2220 int flags = evalarg == NULL ? 0 : evalarg->eval_flags; | 2220 int flags = evalarg == NULL ? 0 : evalarg->eval_flags; |
2221 int end_error = FALSE; | |
2221 | 2222 |
2222 p = skipwhite(arg); | 2223 p = skipwhite(arg); |
2223 ret = eval1(&p, rettv, evalarg); | 2224 ret = eval1(&p, rettv, evalarg); |
2224 p = skipwhite(p); | 2225 p = skipwhite(p); |
2225 | 2226 |
2226 if (ret == FAIL || !ends_excmd2(arg, p)) | 2227 if (ret != FAIL) |
2228 end_error = !ends_excmd2(arg, p); | |
2229 if (ret == FAIL || end_error) | |
2227 { | 2230 { |
2228 if (ret != FAIL) | 2231 if (ret != FAIL) |
2229 clear_tv(rettv); | 2232 clear_tv(rettv); |
2230 /* | 2233 /* |
2231 * Report the invalid expression unless the expression evaluation has | 2234 * Report the invalid expression unless the expression evaluation has |
2236 if (!aborting() | 2239 if (!aborting() |
2237 && did_emsg == did_emsg_before | 2240 && did_emsg == did_emsg_before |
2238 && called_emsg == called_emsg_before | 2241 && called_emsg == called_emsg_before |
2239 && (flags & EVAL_CONSTANT) == 0 | 2242 && (flags & EVAL_CONSTANT) == 0 |
2240 && (!in_vim9script() || !vim9_bad_comment(p))) | 2243 && (!in_vim9script() || !vim9_bad_comment(p))) |
2241 semsg(_(e_invexpr2), arg); | 2244 { |
2245 if (end_error) | |
2246 semsg(_(e_trailing_arg), p); | |
2247 else | |
2248 semsg(_(e_invexpr2), arg); | |
2249 } | |
2242 | 2250 |
2243 // Some of the expression may not have been consumed. Do not check for | 2251 // Some of the expression may not have been consumed. Do not check for |
2244 // a next command to avoid more errors, unless "|" is following, which | 2252 // a next command to avoid more errors, unless "|" is following, which |
2245 // could only be a command separator. | 2253 // could only be a command separator. |
2246 if (eap != NULL && skipwhite(p)[0] == '|' && skipwhite(p)[1] != '|') | 2254 if (eap != NULL && skipwhite(p)[0] == '|' && skipwhite(p)[1] != '|') |