diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-07-29 21:20:41 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-07-29 21:20:41 +0200 |
commit | 696ba23149eb5a7226e606e3fe6f15fdd064c5f7 (patch) | |
tree | 76bcd1a409c844c1e0298581f56098c4b0ba869a /src/eval.c | |
parent | 1040956292a9f2c3d02fc08febd5acf349c85590 (diff) |
patch 8.2.1323: Vim9: invalid operators only rejected in :def functionv8.2.1323
Problem: Vim9: invalid operators only rejected in :def function.
Solution: Also reject them at script level. (closes #6564)
Diffstat (limited to 'src/eval.c')
-rw-r--r-- | src/eval.c | 48 |
1 files changed, 9 insertions, 39 deletions
diff --git a/src/eval.c b/src/eval.c index 81913c7a35..451bb16b7c 100644 --- a/src/eval.c +++ b/src/eval.c @@ -2420,9 +2420,9 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg) { char_u *p; int getnext; - int i; exptype_T type = EXPR_UNKNOWN; int len = 2; + int type_is = FALSE; /* * Get the first variable. @@ -2431,44 +2431,7 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg) return FAIL; p = eval_next_non_blank(*arg, evalarg, &getnext); - switch (p[0]) - { - case '=': if (p[1] == '=') - type = EXPR_EQUAL; - else if (p[1] == '~') - type = EXPR_MATCH; - break; - case '!': if (p[1] == '=') - type = EXPR_NEQUAL; - else if (p[1] == '~') - type = EXPR_NOMATCH; - break; - case '>': if (p[1] != '=') - { - type = EXPR_GREATER; - len = 1; - } - else - type = EXPR_GEQUAL; - break; - case '<': if (p[1] != '=') - { - type = EXPR_SMALLER; - len = 1; - } - else - type = EXPR_SEQUAL; - break; - case 'i': if (p[1] == 's') - { - if (p[2] == 'n' && p[3] == 'o' && p[4] == 't') - len = 5; - i = p[len]; - if (!isalnum(i) && i != '_') - type = len == 2 ? EXPR_IS : EXPR_ISNOT; - } - break; - } + type = get_compare_type(p, &len, &type_is); /* * If there is a comparative operator, use it. @@ -2482,6 +2445,13 @@ eval4(char_u **arg, typval_T *rettv, evalarg_T *evalarg) if (getnext) *arg = eval_next_line(evalarg); + if (vim9script && type_is && (p[len] == '?' || p[len] == '#')) + { + semsg(_(e_invexpr2), p); + clear_tv(rettv); + return FAIL; + } + // extra question mark appended: ignore case if (p[len] == '?') { |