comparison src/testdir/test_vim9_script.vim @ 21479:90d859a402cc v8.2.1290

patch 8.2.1290: Vim9: cannot replace a global function Commit: https://github.com/vim/vim/commit/925e9fd6339981c1015410e1b6a6dd19e34f36cc Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 25 15:41:11 2020 +0200 patch 8.2.1290: Vim9: cannot replace a global function Problem: Vim9: cannot replace a global function. Solution: Allow for "!" on a global function. (closes https://github.com/vim/vim/issues/6524) Also fix that :delfunc on a :def function only made it empty.
author Bram Moolenaar <Bram@vim.org>
date Sat, 25 Jul 2020 15:45:04 +0200
parents 8bcd1ee2630b
children afc8cc1a291f
comparison
equal deleted inserted replaced
21478:d452597ad7ff 21479:90d859a402cc
466 'def DoThat()', 466 'def DoThat()',
467 ' delfunction DeleteMe4', 467 ' delfunction DeleteMe4',
468 'enddef', 468 'enddef',
469 'DoThat()', 469 'DoThat()',
470 ], 'E1084:') 470 ], 'E1084:')
471
472 # Check that global :def function can be replaced and deleted
473 let lines =<< trim END
474 vim9script
475 def g:Global(): string
476 return "yes"
477 enddef
478 assert_equal("yes", g:Global())
479 def! g:Global(): string
480 return "no"
481 enddef
482 assert_equal("no", g:Global())
483 delfunc g:Global
484 assert_false(exists('*g:Global'))
485 END
486 CheckScriptSuccess(lines)
487
488 # Check that global function can be replaced by a :def function and deleted
489 lines =<< trim END
490 vim9script
491 func g:Global()
492 return "yes"
493 endfunc
494 assert_equal("yes", g:Global())
495 def! g:Global(): string
496 return "no"
497 enddef
498 assert_equal("no", g:Global())
499 delfunc g:Global
500 assert_false(exists('*g:Global'))
501 END
502 CheckScriptSuccess(lines)
503
504 # Check that global :def function can be replaced by a function and deleted
505 lines =<< trim END
506 vim9script
507 def g:Global(): string
508 return "yes"
509 enddef
510 assert_equal("yes", g:Global())
511 func! g:Global()
512 return "no"
513 endfunc
514 assert_equal("no", g:Global())
515 delfunc g:Global
516 assert_false(exists('*g:Global'))
517 END
518 CheckScriptSuccess(lines)
471 enddef 519 enddef
472 520
473 func Test_wrong_type() 521 func Test_wrong_type()
474 call CheckDefFailure(['let var: list<nothing>'], 'E1010:') 522 call CheckDefFailure(['let var: list<nothing>'], 'E1010:')
475 call CheckDefFailure(['let var: list<list<nothing>>'], 'E1010:') 523 call CheckDefFailure(['let var: list<list<nothing>>'], 'E1010:')