changeset 20399:d1a54d2bd145 v8.2.0754

patch 8.2.0754: Vim9: No test for forward declaration Commit: https://github.com/vim/vim/commit/a5d0077efbced85fcc63f203937b13efd55d036f Author: Bram Moolenaar <Bram@vim.org> Date: Thu May 14 23:20:55 2020 +0200 patch 8.2.0754: Vim9: No test for forward declaration Problem: Vim9: No test for forward declaration. Solution: Add a test.
author Bram Moolenaar <Bram@vim.org>
date Thu, 14 May 2020 23:30:03 +0200
parents 9d64fe2ee949
children 9a53e38d4abb
files src/testdir/test_vim9_script.vim src/version.c
diffstat 2 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1732,6 +1732,7 @@ def Test_let_func_call()
   END
   writefile(lines, 'Xfinished')
   source Xfinished
+  " GetValue() is not called during discovery phase
   assert_equal(1, g:count)
 
   unlet g:count
@@ -1752,6 +1753,28 @@ def Test_let_missing_type()
   delete('Xfinished')
 enddef
 
+def Test_forward_declaration()
+  let lines =<< trim END
+    vim9script
+    g:initVal = GetValue()
+    def GetValue(): string
+      return theVal
+    enddef
+    let theVal = 'something'
+    theVal = 'else'
+    g:laterVal = GetValue()
+  END
+  writefile(lines, 'Xforward')
+  source Xforward
+  assert_equal('something', g:initVal)
+  assert_equal('else', g:laterVal)
+
+  unlet g:initVal
+  unlet g:laterVal
+  delete('Xforward')
+enddef
+
+
 " Keep this last, it messes up highlighting.
 def Test_substitute_cmd()
   new
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    754,
+/**/
     753,
 /**/
     752,