Mercurial > vim
comparison src/testdir/test_vim9_func.vim @ 24404:a2a7d2d6e724 v8.2.2742
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Commit: https://github.com/vim/vim/commit/701cc6ca9e940665a9424541f989bb38c853a498
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 10 13:33:48 2021 +0200
patch 8.2.2742: Vim9: when compiling a function fails it is cleared
Problem: Vim9: when compiling a function fails it is cleared.
Solution: Keep the function lines, prevent execution with a different
status. (closes #8093)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 10 Apr 2021 13:45:05 +0200 |
parents | 009a540f16a6 |
children | a26f0fa12845 |
comparison
equal
deleted
inserted
replaced
24403:1df57caa70c0 | 24404:a2a7d2d6e724 |
---|---|
1496 assert_fails('so Xdef', 'E1027:', '', 1, 'Func0') | 1496 assert_fails('so Xdef', 'E1027:', '', 1, 'Func0') |
1497 writefile(['def Func2(): string', 'return "Func2"', 'enddef'], 'Xdef') | 1497 writefile(['def Func2(): string', 'return "Func2"', 'enddef'], 'Xdef') |
1498 so Xdef | 1498 so Xdef |
1499 delete('Xdef') | 1499 delete('Xdef') |
1500 | 1500 |
1501 g:Func0()->assert_equal(0) | 1501 assert_fails('g:Func0()', 'E1091:') |
1502 g:Func1()->assert_equal('Func1') | 1502 g:Func1()->assert_equal('Func1') |
1503 g:Func2()->assert_equal('Func2') | 1503 g:Func2()->assert_equal('Func2') |
1504 | 1504 |
1505 delfunc! Func0 | 1505 delfunc! Func0 |
1506 delfunc! Func1 | 1506 delfunc! Func1 |
2589 | 2589 |
2590 CheckScriptSuccess(lines + ['echo H(G(F1))']) | 2590 CheckScriptSuccess(lines + ['echo H(G(F1))']) |
2591 CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:') | 2591 CheckScriptFailure(lines + ['echo H(G(F2))'], 'E1013:') |
2592 enddef | 2592 enddef |
2593 | 2593 |
2594 def Test_compile_error() | |
2595 var lines =<< trim END | |
2596 def g:Broken() | |
2597 echo 'a' + {} | |
2598 enddef | |
2599 call g:Broken() | |
2600 END | |
2601 # First call: compilation error | |
2602 CheckScriptFailure(lines, 'E1051: Wrong argument type for +') | |
2603 | |
2604 # Second call won't try compiling again | |
2605 assert_fails('call g:Broken()', 'E1091: Function is not compiled: Broken') | |
2606 enddef | |
2607 | |
2594 | 2608 |
2595 | 2609 |
2596 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 2610 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |