Mercurial > vim
comparison src/testdir/test_vim9_disassemble.vim @ 27376:1a6421c5be20 v8.2.4216
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Commit: https://github.com/vim/vim/commit/06b77229ca704d00c4f138ed0377556e54d5851f
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jan 25 15:51:56 2022 +0000
patch 8.2.4216: Vim9: cannot use a function from an autoload import directly
Problem: Vim9: cannot use a function from an autoload import directly.
Solution: Add the AUTOLOAD instruction to figure out at runtime.
(closes #9620)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 25 Jan 2022 17:00:06 +0100 |
parents | 7045e9308ca3 |
children | 69a48bcd1d80 |
comparison
equal
deleted
inserted
replaced
27375:90523078c8e2 | 27376:1a6421c5be20 |
---|---|
1 " Test the :disassemble command, and compilation as a side effect | 1 " Test the :disassemble command, and compilation as a side effect |
2 | 2 |
3 source check.vim | 3 source check.vim |
4 source vim9.vim | |
4 | 5 |
5 func NotCompiled() | 6 func NotCompiled() |
6 echo "not" | 7 echo "not" |
7 endfunc | 8 endfunc |
8 | 9 |
284 var localfloat = 1.234 | 285 var localfloat = 1.234 |
285 endif | 286 endif |
286 enddef | 287 enddef |
287 | 288 |
288 def Test_disassemble_push() | 289 def Test_disassemble_push() |
289 var res = execute('disass s:ScriptFuncPush') | 290 mkdir('Xdir/autoload', 'p') |
290 assert_match('<SNR>\d*_ScriptFuncPush.*' .. | 291 var save_rtp = &rtp |
291 'localbool = true.*' .. | 292 exe 'set rtp^=' .. getcwd() .. '/Xdir' |
292 ' PUSH true.*' .. | 293 |
293 'localspec = v:none.*' .. | 294 var lines =<< trim END |
294 ' PUSH v:none.*' .. | 295 vim9script |
295 'localblob = 0z1234.*' .. | 296 END |
296 ' PUSHBLOB 0z1234.*', | 297 writefile(lines, 'Xdir/autoload/autoscript.vim') |
297 res) | 298 |
298 if has('float') | 299 lines =<< trim END |
299 assert_match('<SNR>\d*_ScriptFuncPush.*' .. | 300 vim9script |
300 'localfloat = 1.234.*' .. | 301 import autoload 'autoscript.vim' |
301 ' PUSHF 1.234.*', | 302 |
302 res) | 303 def s:AutoloadFunc() |
303 endif | 304 &operatorfunc = autoscript.Opfunc |
305 enddef | |
306 | |
307 var res = execute('disass s:AutoloadFunc') | |
308 assert_match('<SNR>\d*_AutoloadFunc.*' .. | |
309 '&operatorfunc = autoscript.Opfunc\_s*' .. | |
310 '0 AUTOLOAD autoscript#Opfunc\_s*' .. | |
311 '1 STOREFUNCOPT &operatorfunc\_s*' .. | |
312 '2 RETURN void', | |
313 res) | |
314 END | |
315 CheckScriptSuccess(lines) | |
316 | |
317 delete('Xdir', 'rf') | |
318 &rtp = save_rtp | |
304 enddef | 319 enddef |
305 | 320 |
306 def s:ScriptFuncStore() | 321 def s:ScriptFuncStore() |
307 var localnr = 1 | 322 var localnr = 1 |
308 localnr = 2 | 323 localnr = 2 |