Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
20338:ff4ae3f09307 | 20339:7587d892c00c |
---|---|
1043 ' return arg.*' .. | 1043 ' return arg.*' .. |
1044 ' enddef', | 1044 ' enddef', |
1045 res3) | 1045 res3) |
1046 enddef | 1046 enddef |
1047 | 1047 |
1048 def Test_vim9script_forward_func() | |
1049 let lines =<< trim END | |
1050 vim9script | |
1051 def FuncOne(): string | |
1052 return FuncTwo() | |
1053 enddef | |
1054 def FuncTwo(): string | |
1055 return 'two' | |
1056 enddef | |
1057 let g:res_FuncOne = execute('disass FuncOne') | |
1058 END | |
1059 writefile(lines, 'Xdisassemble') | |
1060 source Xdisassemble | |
1061 | |
1062 " check that the first function calls the second with DCALL | |
1063 assert_match('\<SNR>\d*_FuncOne.*' .. | |
1064 'return FuncTwo().*' .. | |
1065 '\d DCALL <SNR>\d\+_FuncTwo(argc 0).*' .. | |
1066 '\d RETURN', | |
1067 g:res_FuncOne) | |
1068 | |
1069 delete('Xdisassemble') | |
1070 unlet g:res_FuncOne | |
1071 enddef | |
1072 | |
1048 def s:ConcatStrings(): string | 1073 def s:ConcatStrings(): string |
1049 return 'one' .. 'two' .. 'three' | 1074 return 'one' .. 'two' .. 'three' |
1050 enddef | 1075 enddef |
1051 | 1076 |
1052 def s:ComputeConst(): number | 1077 def s:ComputeConst(): number |