]> granicus.if.org Git - vim/commitdiff
patch 8.2.3965: Vim9: no easy way to check if Vim9 script is supported v8.2.3965
authorBram Moolenaar <Bram@vim.org>
Sat, 1 Jan 2022 12:17:00 +0000 (12:17 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 1 Jan 2022 12:17:00 +0000 (12:17 +0000)
Problem:    Vim9: no easy way to check if Vim9 script is supported.
Solution:   Add has('vim9script').

runtime/doc/vim9.txt
src/evalfunc.c
src/testdir/test_vim9_script.vim
src/version.c

index 1dde731ff5aafd0818ea6d9b5a27108979d09946..e79e06e5bb6b55e74d81500fc904b4bfffdaae02 100644 (file)
@@ -391,8 +391,8 @@ later.  Example: >
          endif
        enddef
 
-If you would do it like this you get an error at compile time that
-"PluginFunc" does not exist, even when "g:loaded_plugin" does not exist: >
+If you do it like this, you get an error at compile time that "PluginFunc"
+does not exist, even when "g:loaded_plugin" does not exist: >
        def CallPluginFunc()
          if exists('g:loaded_plugin')
            PluginFunc()   # Error - function not found
@@ -1411,9 +1411,6 @@ This can only work in two ways:
 2. The "if" statement evaluates to true, the commands up to `endif` are
    executed and `finish` bails out before reaching `vim9script`.
 
-TODO: The "vim9script" feature does not exist yet, it will only be added once
-the Vim9 script syntax has been fully implemented.
-
 
 Export ~
                                                        *:export* *:exp*
index 9b49d81e8f7639a60ac39eeb3f85ca5fe69cce2d..d61797ae3157a43f06999f27f3e6ae80a2d5cbec 100644 (file)
@@ -5929,6 +5929,7 @@ f_has(typval_T *argvars, typval_T *rettv)
                0
 #endif
                },
+       {"vim9script", 1},
        {"vimscript-1", 1},
        {"vimscript-2", 1},
        {"vimscript-3", 1},
index f79112ea9ba807419d86c4c077c0a46cd18b584e..8aea267591ae335971ff17626f9bfd4303e8d8af 100644 (file)
@@ -7,6 +7,23 @@ source vim9.vim
 source shared.vim
 source screendump.vim
 
+def Test_vim9script_feature()
+  # example from the help, here the feature is always present
+  var lines =<< trim END
+      " old style comment
+      if !has('vim9script')
+        " legacy commands would go here
+        finish
+      endif
+      vim9script
+      # Vim9 script commands go here
+      g:didit = true
+  END
+  CheckScriptSuccess(lines)
+  assert_equal(true, g:didit)
+  unlet g:didit
+enddef
+
 def Test_range_only()
   new
   setline(1, ['blah', 'Blah'])
index db91b29a7166b745177824f065247dce9cfdafc8..6499548706c97715a7d647ab24faf41ca694852f 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3965,
 /**/
     3964,
 /**/