# HG changeset patch # User Bram Moolenaar # Date 1596046503 -7200 # Node ID 6c67c86a202ac0ea34791cfd0af78789e83e1f9f # Parent 456123afa2ec42d640fe5695d9598e0d4698c83a patch 8.2.1322: Vim9: method on double quoted string doesn't work Commit: https://github.com/vim/vim/commit/1040956292a9f2c3d02fc08febd5acf349c85590 Author: Bram Moolenaar Date: Wed Jul 29 20:00:38 2020 +0200 patch 8.2.1322: Vim9: method on double quoted string doesn't work Problem: Vim9: method on double quoted string doesn't work. Solution: Recognize double quoted string. (closes https://github.com/vim/vim/issues/6562) diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -3277,7 +3277,7 @@ find_ex_command( char_u *pskip = (*eap->cmd == '&' || *eap->cmd == '$' || *eap->cmd == '@') ? eap->cmd + 1 : eap->cmd; - if (vim_strchr((char_u *)"{('[", *p) != NULL + if (vim_strchr((char_u *)"{('[\"", *p) != NULL || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) { int oplen; @@ -3293,6 +3293,8 @@ find_ex_command( *eap->cmd == '{' // "'string'->func()" is an expression. || *eap->cmd == '\'' + // '"string"->func()' is an expression. + || *eap->cmd == '"' // "g:varname" is an expression. || eap->cmd[1] == ':' ) diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1638,8 +1638,9 @@ enddef def Test_expr7_method_call() new setline(1, ['first', 'last']) - eval 'second'->append(1) - assert_equal(['first', 'second', 'last'], getline(1, '$')) + 'second'->append(1) + "third"->append(2) + assert_equal(['first', 'second', 'third', 'last'], getline(1, '$')) bwipe! let bufnr = bufnr() diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim --- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -502,8 +502,11 @@ def Test_vim9script_call() assert_equal('some', var) # line starting with single quote is not a mark + # line starting with double quote can be a method call 'asdfasdf'->MyFunc() assert_equal('asdfasdf', var) + "xyz"->MyFunc() + assert_equal('xyz', var) def UseString() 'xyork'->MyFunc() @@ -511,6 +514,12 @@ def Test_vim9script_call() UseString() assert_equal('xyork', var) + def UseString2() + "knife"->MyFunc() + enddef + UseString2() + assert_equal('knife', var) + # prepending a colon makes it a mark new setline(1, ['aaa', 'bbb', 'ccc']) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1322, +/**/ 1321, /**/ 1320,