comparison src/vim9compile.c @ 25481:a975e2b7ea31 v8.2.3277

patch 8.2.3277: Vim9: compiled has() does not work properly Commit: https://github.com/vim/vim/commit/c3160727b940b762e18fd9431416dc1a4a081c3a Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 2 21:12:05 2021 +0200 patch 8.2.3277: Vim9: compiled has() does not work properly Problem: Vim9: compiled has() does not work properly. Solution: Fix check for has() vs exists().
author Bram Moolenaar <Bram@vim.org>
date Mon, 02 Aug 2021 21:15:03 +0200
parents fbdfa533001c
children 0160aff01c32
comparison
equal deleted inserted replaced
25480:5435994d0135 25481:a975e2b7ea31
3400 if ((varlen == 3 && STRNCMP(*arg, "has", 3) == 0) 3400 if ((varlen == 3 && STRNCMP(*arg, "has", 3) == 0)
3401 || (varlen == 6 && STRNCMP(*arg, "exists", 6) == 0)) 3401 || (varlen == 6 && STRNCMP(*arg, "exists", 6) == 0))
3402 { 3402 {
3403 char_u *s = skipwhite(*arg + varlen + 1); 3403 char_u *s = skipwhite(*arg + varlen + 1);
3404 typval_T argvars[2]; 3404 typval_T argvars[2];
3405 int is_has = **arg == 'h';
3405 3406
3406 argvars[0].v_type = VAR_UNKNOWN; 3407 argvars[0].v_type = VAR_UNKNOWN;
3407 if (*s == '"') 3408 if (*s == '"')
3408 (void)eval_string(&s, &argvars[0], TRUE); 3409 (void)eval_string(&s, &argvars[0], TRUE);
3409 else if (*s == '\'') 3410 else if (*s == '\'')
3410 (void)eval_lit_string(&s, &argvars[0], TRUE); 3411 (void)eval_lit_string(&s, &argvars[0], TRUE);
3411 s = skipwhite(s); 3412 s = skipwhite(s);
3412 if (*s == ')' && argvars[0].v_type == VAR_STRING 3413 if (*s == ')' && argvars[0].v_type == VAR_STRING
3413 && ((**arg == 'h' && !dynamic_feature(argvars[0].vval.v_string)) 3414 && ((is_has && !dynamic_feature(argvars[0].vval.v_string))
3414 || (**arg == 'e' && (*argvars[0].vval.v_string == '+' 3415 || (!is_has && (*argvars[0].vval.v_string == '+'
3415 || *argvars[0].vval.v_string == '&')))) 3416 || *argvars[0].vval.v_string == '&'))))
3416 { 3417 {
3417 typval_T *tv = &ppconst->pp_tv[ppconst->pp_used]; 3418 typval_T *tv = &ppconst->pp_tv[ppconst->pp_used];
3418 3419
3419 *arg = s + 1; 3420 *arg = s + 1;
3420 argvars[1].v_type = VAR_UNKNOWN; 3421 argvars[1].v_type = VAR_UNKNOWN;
3421 tv->v_type = VAR_NUMBER; 3422 tv->v_type = VAR_NUMBER;
3422 tv->vval.v_number = 0; 3423 tv->vval.v_number = 0;
3423 if (**arg == 'h') 3424 if (is_has)
3424 f_has(argvars, tv); 3425 f_has(argvars, tv);
3425 else 3426 else
3426 f_exists(argvars, tv); 3427 f_exists(argvars, tv);
3427 clear_tv(&argvars[0]); 3428 clear_tv(&argvars[0]);
3428 ++ppconst->pp_used; 3429 ++ppconst->pp_used;
7094 break; 7095 break;
7095 7096
7096 if (oplen > 0 && *op != '=') 7097 if (oplen > 0 && *op != '=')
7097 { 7098 {
7098 type_T *expected; 7099 type_T *expected;
7099 type_T *stacktype; 7100 type_T *stacktype = NULL;
7100 7101
7101 if (*op == '.') 7102 if (*op == '.')
7102 { 7103 {
7103 if (may_generate_2STRING(-1, FALSE, cctx) == FAIL) 7104 if (may_generate_2STRING(-1, FALSE, cctx) == FAIL)
7104 goto theend; 7105 goto theend;