Mercurial > vim
comparison src/testdir/test_vim9_import.vim @ 27807:292a6bd86c30 v8.2.4429
patch 8.2.4429: using script-local function from the wrong script
Commit: https://github.com/vim/vim/commit/c2f17f7e64bb1bf872dbc6f3b8f0d8751e275287
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 21 13:13:50 2022 +0000
patch 8.2.4429: using script-local function from the wrong script
Problem: Using script-local function from the wrong script when using a
partial. (Yegappan Lakshmanan)
Solution: Include the script ID in the partial name.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 21 Feb 2022 14:15:04 +0100 |
parents | 60ac4228a73d |
children | 6e431b1c51d5 |
comparison
equal
deleted
inserted
replaced
27806:c8db1c5f9303 | 27807:292a6bd86c30 |
---|---|
421 v9.CheckScriptSuccess(lines) | 421 v9.CheckScriptSuccess(lines) |
422 | 422 |
423 delete('Xlib.vim') | 423 delete('Xlib.vim') |
424 enddef | 424 enddef |
425 | 425 |
426 def Test_import_duplicate_function() | |
427 # Function Hover() exists in both scripts, partial should refer to the right | |
428 # one. | |
429 var lines =<< trim END | |
430 vim9script | |
431 | |
432 def Hover(d: dict<any>): string | |
433 return 'found it' | |
434 enddef | |
435 | |
436 export def NewLspServer(): dict<any> | |
437 var d: dict<any> = {} | |
438 d->extend({hover: function('Hover', [d])}) | |
439 return d | |
440 enddef | |
441 | |
442 NewLspServer() | |
443 END | |
444 writefile(lines, 'Xserver.vim') | |
445 | |
446 lines =<< trim END | |
447 vim9script | |
448 | |
449 import './Xserver.vim' as server | |
450 | |
451 export def Hover() | |
452 enddef | |
453 | |
454 def AddServer() | |
455 var d: dict<any> = server.NewLspServer() | |
456 assert_equal('found it', d.hover()) | |
457 enddef | |
458 AddServer() | |
459 END | |
460 v9.CheckScriptSuccess(lines) | |
461 | |
462 delete('Xserver.vim') | |
463 enddef | |
464 | |
465 | |
426 def Test_import_fails() | 466 def Test_import_fails() |
427 writefile([], 'Xfoo.vim') | 467 writefile([], 'Xfoo.vim') |
428 var lines =<< trim END | 468 var lines =<< trim END |
429 import './Xfoo.vim' as foo | 469 import './Xfoo.vim' as foo |
430 foo = 'bar' | 470 foo = 'bar' |