]> granicus.if.org Git - vim/commitdiff
patch 8.2.1322: Vim9: method on double quoted string doesn't work v8.2.1322
authorBram Moolenaar <Bram@vim.org>
Wed, 29 Jul 2020 18:00:38 +0000 (20:00 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 29 Jul 2020 18:00:38 +0000 (20:00 +0200)
Problem:    Vim9: method on double quoted string doesn't work.
Solution:   Recognize double quoted string. (closes #6562)

src/ex_docmd.c
src/testdir/test_vim9_expr.vim
src/testdir/test_vim9_func.vim
src/version.c

index 536850edc9f65d544f8b20b0c064720f99dd5904..ad1693b516f1c3756cb89eed1ce06a4af111e5e9 100644 (file)
@@ -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] == ':'
                            )
index 5b46c32f96e201ef32b8e1fd7524226d7349d23d..e29ef5cf0e575978b402ec73c221f070e142809f 100644 (file)
@@ -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()
index c05e98e70451a581303064c1dac107aef3feb9ca..2546f1369fdda8cf1f416f2d9c6331e6fdc24f09 100644 (file)
@@ -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'])
index db2e9b42b1b8d9e70e341e927d808c2ba101d91c..bb1c4ab413c6267a71ec59a7c156090c0a6745fd 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1322,
 /**/
     1321,
 /**/