Mercurial > vim
changeset 24462:7c4f50c02e18 v8.2.2771
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Commit: https://github.com/vim/vim/commit/aa1959bd5e82350bb4a82d9a5188c29d70706ec4
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Apr 15 22:13:39 2021 +0200
patch 8.2.2771: Vim9: assignment not recognized if declaration was skipped
Problem: Vim9: assignment not recognized if declaration was skipped.
Solution: Also recognized an assignment if the variable does not exist.
(closes #8108)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 15 Apr 2021 22:15:03 +0200 |
parents | 550096cdfa95 |
children | 754a22f6d5bc |
files | src/ex_docmd.c src/testdir/test_vim9_assign.vim src/version.c |
diffstat | 3 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3483,7 +3483,8 @@ find_ex_command( // Recognize an assignment if we recognize the variable name: // "g:var = expr" - // "var = expr" where "var" is a variable name. + // "var = expr" where "var" is a variable name or we are skipping + // (variable declaration might have been skipped). if (*eap->cmd == '@') p = eap->cmd + 2; oplen = assignment_len(skipwhite(p), &heredoc); @@ -3493,6 +3494,7 @@ find_ex_command( || *eap->cmd == '&' || *eap->cmd == '$' || *eap->cmd == '@' + || eap->skip || lookup(eap->cmd, p - eap->cmd, TRUE, cctx) == OK) { eap->cmdidx = CMD_var;
--- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -249,6 +249,18 @@ def Test_assignment() END enddef +def Test_skipped_assignment() + var lines =<< trim END + for x in [] + var i: number = 1 + while false + i += 1 + endwhile + endfor + END + CheckDefAndScriptSuccess(lines) +enddef + def Test_assign_unpack() var lines =<< trim END var v1: number