Mercurial > vim
comparison src/ex_docmd.c @ 19481:c27837cbe922 v8.2.0298
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Commit: https://github.com/vim/vim/commit/0c6ceaf90389b41545d803458c4813013811c756
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 22 18:36:32 2020 +0100
patch 8.2.0298: Vim9 script: cannot start command with a string constant
Problem: Vim9 script: cannot start command with a string constant.
Solution: Recognize expression starting with '('.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 22 Feb 2020 18:45:04 +0100 |
parents | 5512aa74cb62 |
children | 639b1d672757 |
comparison
equal
deleted
inserted
replaced
19480:341343c30a23 | 19481:c27837cbe922 |
---|---|
3144 #ifdef FEAT_EVAL | 3144 #ifdef FEAT_EVAL |
3145 /* | 3145 /* |
3146 * Recognize a Vim9 script function/method call and assignment: | 3146 * Recognize a Vim9 script function/method call and assignment: |
3147 * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()" | 3147 * "lvar = value", "lvar(arg)", "[1, 2 3]->Func()" |
3148 */ | 3148 */ |
3149 if (lookup != NULL && (p = to_name_const_end(eap->cmd)) > eap->cmd | 3149 p = eap->cmd; |
3150 && *p != NUL) | 3150 if (lookup != NULL && (*p == '(' |
3151 || ((p = to_name_const_end(eap->cmd)) > eap->cmd && *p != NUL))) | |
3151 { | 3152 { |
3152 int oplen; | 3153 int oplen; |
3153 int heredoc; | 3154 int heredoc; |
3154 | 3155 |
3155 // "funcname(" is always a function call. | 3156 // "funcname(" is always a function call. |
3156 // "varname[]" is an expression. | 3157 // "varname[]" is an expression. |
3157 // "g:varname" is an expression. | 3158 // "g:varname" is an expression. |
3158 // "varname->expr" is an expression. | 3159 // "varname->expr" is an expression. |
3160 // "(..." is an expression. | |
3159 if (*p == '(' | 3161 if (*p == '(' |
3160 || *p == '[' | 3162 || *p == '[' |
3161 || p[1] == ':' | 3163 || p[1] == ':' |
3162 || (*p == '-' && p[1] == '>')) | 3164 || (*p == '-' && p[1] == '>')) |
3163 { | 3165 { |