diff src/testdir/test_vim9_disassemble.vim @ 20339:7587d892c00c v8.2.0725

patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script Commit: https://github.com/vim/vim/commit/09689a02840be40fa7bb10b1921fb5bc5b2908f1 Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 9 22:50:08 2020 +0200 patch 8.2.0725: Vim9: cannot call a function declared later in Vim9 script Problem: Vim9: cannot call a function declared later in Vim9 script. Solution: Make two passes through the script file.
author Bram Moolenaar <Bram@vim.org>
date Sat, 09 May 2020 23:00:04 +0200
parents 2fd980fb9ab3
children c225be44692a
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -1045,6 +1045,31 @@ def Test_display_func()
         res3)
 enddef
 
+def Test_vim9script_forward_func()
+  let lines =<< trim END
+    vim9script
+    def FuncOne(): string
+      return FuncTwo()
+    enddef
+    def FuncTwo(): string
+      return 'two'
+    enddef
+    let g:res_FuncOne = execute('disass FuncOne')
+  END
+  writefile(lines, 'Xdisassemble')
+  source Xdisassemble
+
+  " check that the first function calls the second with DCALL
+  assert_match('\<SNR>\d*_FuncOne.*' ..
+        'return FuncTwo().*' ..
+        '\d DCALL <SNR>\d\+_FuncTwo(argc 0).*' ..
+        '\d RETURN',
+        g:res_FuncOne)
+
+  delete('Xdisassemble')
+  unlet g:res_FuncOne
+enddef
+
 def s:ConcatStrings(): string
   return 'one' .. 'two' .. 'three'
 enddef