]> granicus.if.org Git - vim/commitdiff
patch 8.2.3835: the inline-function example does not work v8.2.3835
authorBram Moolenaar <Bram@vim.org>
Fri, 17 Dec 2021 12:45:22 +0000 (12:45 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 17 Dec 2021 12:45:22 +0000 (12:45 +0000)
Problem:    The inline-function example does not work.
Solution:   Drop ":let".  Add EX_EXPR_ARG to CMD_var. (issue #9352)

runtime/doc/vim9.txt
src/ex_cmds.h
src/testdir/test_vim9_expr.vim
src/version.c

index 990d759e6c32b22078ac0b909d8d35957daeff6c..39affbfc2c4f9ab53f2c25957776d0b1126ac4fe 100644 (file)
@@ -560,7 +560,6 @@ This can be useful for a timer, for example: >
                 echom 'Handler called ' .. count
             }, {repeat: 3})
 
-
 The ending "}" must be at the start of a line.  It can be followed by other
 characters, e.g.: >
        var d = mapnew(dict, (k, v): string => {
@@ -568,17 +567,21 @@ characters, e.g.: >
           })
 No command can follow the "{", only a comment can be used there.
 
+                                                       *command-block*
+The block can also be used for defining a user command.  Inside the block Vim9
+syntax will be used.
+
 If the statements include a dictionary, its closing bracket must not be
 written at the start of a line.  Otherwise, it would be parsed as the end of
 the block.  This does not work: >
        command NewCommand {
-            let g:mydict = {
+            g:mydict = {
               'key': 'value',
               }  # ERROR: will be recognized as the end of the block
           }
 Put the '}' after the last item to avoid this: >
        command NewCommand {
-            let g:mydict = {
+            g:mydict = {
               'key': 'value' }
           }
 
index c2657b0ff36d873270ce1fc47a8df361bf7a46de..044580a7c1d54dc850661c124687191c061d8c02 100644 (file)
@@ -1691,7 +1691,7 @@ EXCMD(CMD_vglobal,        "vglobal",      ex_global,
        EX_RANGE|EX_WHOLEFOLD|EX_EXTRA|EX_DFLALL|EX_CMDWIN|EX_LOCK_OK|EX_NONWHITE_OK,
        ADDR_LINES),
 EXCMD(CMD_var,         "var",          ex_var,
-       EX_EXTRA|EX_NOTRLCOM|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
+       EX_EXTRA|EX_NOTRLCOM|EX_EXPR_ARG|EX_SBOXOK|EX_CMDWIN|EX_LOCK_OK,
        ADDR_NONE),
 EXCMD(CMD_version,     "version",      ex_version,
        EX_EXTRA|EX_TRLBAR|EX_CMDWIN|EX_LOCK_OK,
index e374788dba4eef77e6cfac72a43572bf9fd43a13..685bde2ece8f57dffe18515d130c722db6d4054a 100644 (file)
@@ -2557,10 +2557,19 @@ def Test_expr7_dict_in_block()
               k: 0, }
       }
       MyCommand
+
+      command YourCommand {
+         g:global = {
+           key: 'value' }
+         }
+      YourCommand
+      assert_equal({key: 'value'}, g:global)
+      unlet g:global
   END
   CheckScriptSuccess(lines)
 
   delcommand MyCommand
+  delcommand YourCommand
 enddef
 
 def Test_expr7_call_2bool()
index 368384c9a2d8b5db478ee478e10090cdb5f1efab..7b2c4845922a82cdfd3c462d5156cb5f9e15052d 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3835,
 /**/
     3834,
 /**/