summaryrefslogtreecommitdiffstats
path: root/src/ex_eval.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-07-10 19:42:03 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-10 19:42:03 +0200
commitc323527d67081cfaff22503d1d282495976c7042 (patch)
treec59f38df837b94ee91d62ab3c7d6cdefe32b5fce /src/ex_eval.c
parentfe3418abe0dac65e42e85b5a91c5d0c975bc65bb (diff)
patch 8.2.3137: Vim9: no error when a line only has a variable namev8.2.3137
Problem: Vim9: no error when a line only has a variable name. Solution: Give an error when an expression is evaluated without an effect. (closes #8538)
Diffstat (limited to 'src/ex_eval.c')
-rw-r--r--src/ex_eval.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/ex_eval.c b/src/ex_eval.c
index b504763dfc..08ba858876 100644
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -208,7 +208,7 @@ cause_errthrow(
* not skipped. Errors in those commands may affect what of the subsequent
* commands are regarded part of catch and finally clauses. Catching the
* exception would then cause execution of commands not intended by the
- * user, who wouldn't even get aware of the problem. Therefor, discard the
+ * user, who wouldn't even get aware of the problem. Therefore, discard the
* exception currently being thrown to prevent it from being caught. Just
* execute finally clauses and terminate.
*/
@@ -896,11 +896,28 @@ ex_eval(exarg_T *eap)
{
typval_T tv;
evalarg_T evalarg;
+ int name_only = FALSE;
+ char_u *p;
+ long lnum = SOURCING_LNUM;
+
+ if (in_vim9script())
+ {
+ char_u *alias;
+
+ p = eap->arg;
+ get_name_len(&p, &alias, FALSE, FALSE);
+ name_only = ends_excmd2(eap->arg, skipwhite(p));
+ vim_free(alias);
+ }
fill_evalarg_from_eap(&evalarg, eap, eap->skip);
if (eval0(eap->arg, &tv, eap, &evalarg) == OK)
+ {
clear_tv(&tv);
+ if (in_vim9script() && name_only && lnum == SOURCING_LNUM)
+ semsg(_(e_expression_without_effect_str), eap->arg);
+ }
clear_evalarg(&evalarg, eap);
}
@@ -1287,7 +1304,7 @@ ex_continue(exarg_T *eap)
{
// Try to find the matching ":while". This might stop at a try
// conditional not in its finally clause (which is then to be executed
- // next). Therefor, inactivate all conditionals except the ":while"
+ // next). Therefore, inactivate all conditionals except the ":while"
// itself (if reached).
idx = cleanup_conditionals(cstack, CSF_WHILE | CSF_FOR, FALSE);
if (idx >= 0 && (cstack->cs_flags[idx] & (CSF_WHILE | CSF_FOR)))