Mercurial > vim
comparison src/testdir/test_usercommands.vim @ 27457:4c16acb2525f v8.2.4257
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Commit: https://github.com/vim/vim/commit/62aec93bfdb9e1b40d03a6d2e8e9511f8b1bdb2d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 29 21:45:34 2022 +0000
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistent
Problem: Vim9: finding global function without g: prefix but not finding
global variable is inconsistent.
Solution: Require using g: for a global function. Change the vim9.vim
script into a Vim9 script with exports. Fix that import in legacy
script does not work.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 29 Jan 2022 23:00:05 +0100 |
parents | 8950a7b6cc89 |
children | 38eab98ef5a9 |
comparison
equal
deleted
inserted
replaced
27456:a8e2d91995ce | 27457:4c16acb2525f |
---|---|
1 " Tests for user defined commands | 1 " Tests for user defined commands |
2 | 2 |
3 source vim9.vim | 3 import './vim9.vim' as v9 |
4 | 4 |
5 " Test for <mods> in user defined commands | 5 " Test for <mods> in user defined commands |
6 function Test_cmdmods() | 6 function Test_cmdmods() |
7 let g:mods = '' | 7 let g:mods = '' |
8 | 8 |
285 | 285 |
286 let lines =<< trim END | 286 let lines =<< trim END |
287 vim9script | 287 vim9script |
288 com! -complete=file DoCmd : | 288 com! -complete=file DoCmd : |
289 END | 289 END |
290 call CheckScriptFailure(lines, 'E1208', 2) | 290 call v9.CheckScriptFailure(lines, 'E1208', 2) |
291 | 291 |
292 let lines =<< trim END | 292 let lines =<< trim END |
293 vim9script | 293 vim9script |
294 com! -nargs=0 -complete=file DoCmd : | 294 com! -nargs=0 -complete=file DoCmd : |
295 END | 295 END |
296 call CheckScriptFailure(lines, 'E1208', 2) | 296 call v9.CheckScriptFailure(lines, 'E1208', 2) |
297 | 297 |
298 com! -nargs=0 DoCmd : | 298 com! -nargs=0 DoCmd : |
299 call assert_fails('DoCmd x', 'E488:') | 299 call assert_fails('DoCmd x', 'E488:') |
300 | 300 |
301 com! -nargs=1 DoCmd : | 301 com! -nargs=1 DoCmd : |
643 | 643 |
644 let lines =<< trim END | 644 let lines =<< trim END |
645 command DoesNotEnd { | 645 command DoesNotEnd { |
646 echo 'hello' | 646 echo 'hello' |
647 END | 647 END |
648 call CheckScriptFailure(lines, 'E1026:') | 648 call v9.CheckScriptFailure(lines, 'E1026:') |
649 | 649 |
650 let lines =<< trim END | 650 let lines =<< trim END |
651 command HelloThere { | 651 command HelloThere { |
652 echo 'hello' | echo 'there' | 652 echo 'hello' | echo 'there' |
653 } | 653 } |
654 HelloThere | 654 HelloThere |
655 END | 655 END |
656 call CheckScriptSuccess(lines) | 656 call v9.CheckScriptSuccess(lines) |
657 delcommand HelloThere | 657 delcommand HelloThere |
658 | 658 |
659 let lines =<< trim END | 659 let lines =<< trim END |
660 command BadCommand { | 660 command BadCommand { |
661 echo { | 661 echo { |
662 'key': 'value', | 662 'key': 'value', |
663 } | 663 } |
664 } | 664 } |
665 BadCommand | 665 BadCommand |
666 END | 666 END |
667 call CheckScriptFailure(lines, 'E1128:') | 667 call v9.CheckScriptFailure(lines, 'E1128:') |
668 endfunc | 668 endfunc |
669 | 669 |
670 func Test_delcommand_buffer() | 670 func Test_delcommand_buffer() |
671 command Global echo 'global' | 671 command Global echo 'global' |
672 command -buffer OneBuffer echo 'one' | 672 command -buffer OneBuffer echo 'one' |