diff options
-rw-r--r-- | src/eval.c | 11 | ||||
-rw-r--r-- | src/evalvars.c | 7 | ||||
-rw-r--r-- | src/proto/eval.pro | 2 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 24 | ||||
-rw-r--r-- | src/userfunc.c | 2 | ||||
-rw-r--r-- | src/version.c | 2 |
6 files changed, 39 insertions, 9 deletions
diff --git a/src/eval.c b/src/eval.c index fe4dbd10bb..7fed2867d1 100644 --- a/src/eval.c +++ b/src/eval.c @@ -3481,6 +3481,7 @@ eval7( && (evalarg->eval_flags & EVAL_EVALUATE); int len; char_u *s; + char_u *name_start = NULL; char_u *start_leader, *end_leader; int ret = OK; char_u *alias; @@ -3713,8 +3714,11 @@ eval7( ret = OK; } else + { + name_start = s; ret = eval_variable(s, len, 0, rettv, NULL, EVAL_VAR_VERBOSE + EVAL_VAR_IMPORT); + } } else { @@ -3729,7 +3733,7 @@ eval7( // Handle following '[', '(' and '.' for expr[expr], expr.name, // expr(expr), expr->name(expr) if (ret == OK) - ret = handle_subscript(arg, rettv, evalarg, TRUE); + ret = handle_subscript(arg, name_start, rettv, evalarg, TRUE); /* * Apply logical NOT and unary '-', from right to left, ignore '+'. @@ -5891,10 +5895,12 @@ eval_isdictc(int c) * - method call: var->method() * * Can all be combined in any order: dict.func(expr)[idx]['func'](expr)->len() + * "name_start" points to a variable before the subscript or is NULL. */ int handle_subscript( char_u **arg, + char_u *name_start, typval_T *rettv, evalarg_T *evalarg, int verbose) // give error messages @@ -5936,7 +5942,8 @@ handle_subscript( if (**arg != '.') { if (verbose) - semsg(_(e_expected_str_but_got_str), "'.'", *arg); + semsg(_(e_expected_dot_after_name_str), + name_start != NULL ? name_start: *arg); ret = FAIL; break; } diff --git a/src/evalvars.c b/src/evalvars.c index 2de6f224b7..730c7d1228 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -1239,8 +1239,8 @@ list_arg_vars(exarg_T *eap, char_u *arg, int *first) { // handle d.key, l[idx], f(expr) arg_subsc = arg; - if (handle_subscript(&arg, &tv, &EVALARG_EVALUATE, TRUE) - == FAIL) + if (handle_subscript(&arg, name_start, &tv, + &EVALARG_EVALUATE, TRUE) == FAIL) error = TRUE; else { @@ -3955,7 +3955,8 @@ var_exists(char_u *var) { // handle d.key, l[idx], f(expr) arg = skipwhite(arg); - n = (handle_subscript(&arg, &tv, &EVALARG_EVALUATE, FALSE) == OK); + n = (handle_subscript(&arg, name, &tv, &EVALARG_EVALUATE, + FALSE) == OK); if (n) clear_tv(&tv); } diff --git a/src/proto/eval.pro b/src/proto/eval.pro index f7fa647375..ac4a51cd93 100644 --- a/src/proto/eval.pro +++ b/src/proto/eval.pro @@ -70,7 +70,7 @@ char_u *find_name_end(char_u *arg, char_u **expr_start, char_u **expr_end, int f int eval_isnamec(int c); int eval_isnamec1(int c); int eval_isdictc(int c); -int handle_subscript(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int verbose); +int handle_subscript(char_u **arg, char_u *name_start, typval_T *rettv, evalarg_T *evalarg, int verbose); int item_copy(typval_T *from, typval_T *to, int deep, int copyID); void echo_one(typval_T *rettv, int with_space, int *atstart, int *needclr); void ex_echo(exarg_T *eap); diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index 4c5d9e9a0d..19eee76c78 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -1265,6 +1265,26 @@ def Test_vim9_import_export() unlet g:imported_func delete('Ximport_lbr.vim') + var line_break_before_dot =<< trim END + vim9script + import './Xexport.vim' as expo + g:exported = expo + .exported + END + writefile(line_break_before_dot, 'Ximport_lbr_before_dot.vim') + assert_fails('source Ximport_lbr_before_dot.vim', 'E1060:', '', 3) + delete('Ximport_lbr_before_dot.vim') + + var line_break_after_dot =<< trim END + vim9script + import './Xexport.vim' as expo + g:exported = expo. + exported + END + writefile(line_break_after_dot, 'Ximport_lbr_after_dot.vim') + assert_fails('source Ximport_lbr_after_dot.vim', 'E1074:', '', 3) + delete('Ximport_lbr_after_dot.vim') + var import_star_as_lines =<< trim END vim9script import './Xexport.vim' as Export @@ -1333,7 +1353,7 @@ def Test_vim9_import_export() g:imported_script = Export exported END writefile(import_star_as_lines_script_no_dot, 'Ximport.vim') - assert_fails('source Ximport.vim', 'E1029:') + assert_fails('source Ximport.vim', 'E1060: Expected dot after name: Export exported') var import_star_as_lines_script_space_after_dot =<< trim END vim9script @@ -1519,7 +1539,7 @@ def Test_import_star_fails() import './Xfoo.vim' as foo var that = foo END - CheckScriptFailure(lines, 'E1029: Expected ''.''') + CheckScriptFailure(lines, 'E1060: Expected dot after name: foo') lines =<< trim END vim9script diff --git a/src/userfunc.c b/src/userfunc.c index f9bf5e3316..7446d6ec93 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -5170,7 +5170,7 @@ ex_call(exarg_T *eap) dbg_check_breakpoint(eap); // Handle a function returning a Funcref, Dictionary or List. - if (handle_subscript(&arg, &rettv, + if (handle_subscript(&arg, NULL, &rettv, eap->skip ? NULL : &EVALARG_EVALUATE, TRUE) == FAIL) { failed = TRUE; diff --git a/src/version.c b/src/version.c index cb331fa12c..d8fe3528fd 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4024, +/**/ 4023, /**/ 4022, |