Mercurial > vim
comparison src/testdir/test_vim9_import.vim @ 30705:12e6c7bae2a9 v9.0.0687
patch 9.0.0687: "export def" does not work in a nested block
Commit: https://github.com/vim/vim/commit/5ab300195b0831cbdba3ce349416a0e6a218e4ef
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Oct 7 17:26:22 2022 +0100
patch 9.0.0687: "export def" does not work in a nested block
Problem: "export def" does not work in a nested block.
Solution: Do not handle "export" with a separate function but in the same
command stack. (closes #11304)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 07 Oct 2022 18:30:06 +0200 |
parents | 9c141768fa0f |
children | d50d32026617 |
comparison
equal
deleted
inserted
replaced
30704:2721bdcfeadd | 30705:12e6c7bae2a9 |
---|---|
450 v9.CheckScriptSuccess(lines) | 450 v9.CheckScriptSuccess(lines) |
451 | 451 |
452 delete('Xlib.vim') | 452 delete('Xlib.vim') |
453 enddef | 453 enddef |
454 | 454 |
455 def Test_export_closure() | |
456 # tests that the closure in block can be compiled, not the import part | |
457 var lines =<< trim END | |
458 vim9script | |
459 { | |
460 var foo = 42 | |
461 export def Bar(): number | |
462 return foo | |
463 enddef | |
464 } | |
465 assert_equal(42, Bar()) | |
466 END | |
467 v9.CheckScriptSuccess(lines) | |
468 enddef | |
469 | |
455 def Test_import_duplicate_function() | 470 def Test_import_duplicate_function() |
456 # Function Hover() exists in both scripts, partial should refer to the right | 471 # Function Hover() exists in both scripts, partial should refer to the right |
457 # one. | 472 # one. |
458 var lines =<< trim END | 473 var lines =<< trim END |
459 vim9script | 474 vim9script |
1511 v9.CheckScriptFailure(['export var some = 123'], 'E1042:') | 1526 v9.CheckScriptFailure(['export var some = 123'], 'E1042:') |
1512 v9.CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') | 1527 v9.CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') |
1513 v9.CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') | 1528 v9.CheckScriptFailure(['vim9script', 'export echo 134'], 'E1043:') |
1514 v9.CheckScriptFailure(['vim9script', 'export function /a1b2c3'], 'E1044:') | 1529 v9.CheckScriptFailure(['vim9script', 'export function /a1b2c3'], 'E1044:') |
1515 | 1530 |
1516 assert_fails('export something', 'E1043:') | 1531 assert_fails('export echo 1', 'E1043:') |
1517 enddef | 1532 enddef |
1518 | 1533 |
1519 func Test_import_fails_without_script() | 1534 func Test_import_fails_without_script() |
1520 CheckRunVimInTerminal | 1535 CheckRunVimInTerminal |
1521 | 1536 |