Mercurial > vim
comparison src/evalvars.c @ 21630:3c6c52fbc8ea v8.2.1365
patch 8.2.1365: Vim9: no error for missing white space around operator
Commit: https://github.com/vim/vim/commit/bb1b5e24ecc0abe1fee164e9de13796989eff784
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 5 10:53:21 2020 +0200
patch 8.2.1365: Vim9: no error for missing white space around operator
Problem: Vim9: no error for missing white space around operator.
Solution: Check for white space. (closes https://github.com/vim/vim/issues/6618)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 05 Aug 2020 11:00:08 +0200 |
parents | 586241ee8096 |
children | f41c646cb8b9 |
comparison
equal
deleted
inserted
replaced
21629:87a1c4717817 | 21630:3c6c52fbc8ea |
---|---|
1135 } | 1135 } |
1136 error = TRUE; | 1136 error = TRUE; |
1137 } | 1137 } |
1138 else | 1138 else |
1139 { | 1139 { |
1140 arg = skipwhite(arg); | |
1140 if (tofree != NULL) | 1141 if (tofree != NULL) |
1141 name = tofree; | 1142 name = tofree; |
1142 if (eval_variable(name, len, &tv, NULL, TRUE, FALSE) == FAIL) | 1143 if (eval_variable(name, len, &tv, NULL, TRUE, FALSE) == FAIL) |
1143 error = TRUE; | 1144 error = TRUE; |
1144 else | 1145 else |
3356 } | 3357 } |
3357 | 3358 |
3358 int | 3359 int |
3359 var_exists(char_u *var) | 3360 var_exists(char_u *var) |
3360 { | 3361 { |
3362 char_u *arg = var; | |
3361 char_u *name; | 3363 char_u *name; |
3362 char_u *tofree; | 3364 char_u *tofree; |
3363 typval_T tv; | 3365 typval_T tv; |
3364 int len = 0; | 3366 int len = 0; |
3365 int n = FALSE; | 3367 int n = FALSE; |
3366 | 3368 |
3367 // get_name_len() takes care of expanding curly braces | 3369 // get_name_len() takes care of expanding curly braces |
3368 name = var; | 3370 name = var; |
3369 len = get_name_len(&var, &tofree, TRUE, FALSE); | 3371 len = get_name_len(&arg, &tofree, TRUE, FALSE); |
3370 if (len > 0) | 3372 if (len > 0) |
3371 { | 3373 { |
3372 if (tofree != NULL) | 3374 if (tofree != NULL) |
3373 name = tofree; | 3375 name = tofree; |
3374 n = (eval_variable(name, len, &tv, NULL, FALSE, TRUE) == OK); | 3376 n = (eval_variable(name, len, &tv, NULL, FALSE, TRUE) == OK); |
3375 if (n) | 3377 if (n) |
3376 { | 3378 { |
3377 // handle d.key, l[idx], f(expr) | 3379 // handle d.key, l[idx], f(expr) |
3378 n = (handle_subscript(&var, &tv, &EVALARG_EVALUATE, FALSE) == OK); | 3380 arg = skipwhite(arg); |
3381 n = (handle_subscript(&arg, &tv, &EVALARG_EVALUATE, FALSE) == OK); | |
3379 if (n) | 3382 if (n) |
3380 clear_tv(&tv); | 3383 clear_tv(&tv); |
3381 } | 3384 } |
3382 } | 3385 } |
3383 if (*var != NUL) | 3386 if (*arg != NUL) |
3384 n = FALSE; | 3387 n = FALSE; |
3385 | 3388 |
3386 vim_free(tofree); | 3389 vim_free(tofree); |
3387 return n; | 3390 return n; |
3388 } | 3391 } |