]> granicus.if.org Git - vim/commitdiff
patch 8.2.1157: Vim9: dict.name is not recognized as an expression v8.2.1157
authorBram Moolenaar <Bram@vim.org>
Wed, 8 Jul 2020 16:30:06 +0000 (18:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 8 Jul 2020 16:30:06 +0000 (18:30 +0200)
Problem:    Vim9: dict.name is not recognized as an expression.
Solution:   Recognize ".name". (closes #6418)

src/ex_docmd.c
src/testdir/test_vim9_cmd.vim
src/version.c

index 59778eb981ab92d9b199fcd74087b98af305a933..0573897b7c7f03f0d63defd770b97b8bec9641ca 100644 (file)
@@ -3229,13 +3229,15 @@ find_ex_command(
        // "varname[]" is an expression.
        // "g:varname" is an expression.
        // "varname->expr" is an expression.
+       // "varname.expr" is an expression.
        // "(..." is an expression.
        // "{..." is an dict expression.
        if (*p == '('
                || *p == '{'
                || (*p == '[' && p > eap->cmd)
                || p[1] == ':'
-               || (*p == '-' && p[1] == '>'))
+               || (*p == '-' && p[1] == '>')
+               || (*p == '.' && ASCII_ISALPHA(p[1])))
        {
            eap->cmdidx = CMD_eval;
            return eap->cmd;
index 14af261713242800dd97715a85377a49ddf15a30..801404d9c6f81bf1333c9aa7eec6f94da53c2ac2 100644 (file)
@@ -208,6 +208,23 @@ def Test_method_call_linebreak()
   CheckScriptSuccess(lines)
 enddef
 
+def Test_dict_member()
+   let test: dict<list<number>> = {'data': [3, 1, 2]}
+   test.data->sort()
+   assert_equal(#{data: [1, 2, 3]}, test)
+   test.data
+      ->reverse()
+   assert_equal(#{data: [3, 2, 1]}, test)
+
+  let lines =<< trim END
+      vim9script
+      let test: dict<list<number>> = {'data': [3, 1, 2]}
+      test.data->sort()
+      assert_equal(#{data: [1, 2, 3]}, test)
+  END
+  CheckScriptSuccess(lines)
+enddef
+
 def Test_bar_after_command()
   def RedrawAndEcho()
     let x = 'did redraw'
index e362e270572e68b13c138200f907d47b09aebd50..a54d33bcbfa9383b9270a0c0debb614b4755548f 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1157,
 /**/
     1156,
 /**/