Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 25656:fe7f45e2895e v8.2.3364
patch 8.2.3364: Vim9: crash when :for is skipped
Commit: https://github.com/vim/vim/commit/bebf06954e1c801870b57e06ab03151c2654d079
Author: rbtnn <naru123456789@gmail.com>
Date: Sat Aug 21 17:26:50 2021 +0200
patch 8.2.3364: Vim9: crash when :for is skipped
Problem: Vim9: crash when :for is skipped.
Solution: Skip more code generation. (Naruhiko Nishino, closes https://github.com/vim/vim/issues/8777)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 21 Aug 2021 17:30:03 +0200 |
parents | ef38fc02faaa |
children | fc8046209eaa |
comparison
equal
deleted
inserted
replaced
25655:cf7cd75766d9 | 25656:fe7f45e2895e |
---|---|
2550 writefile(lines, 'Xvim9for.vim') | 2550 writefile(lines, 'Xvim9for.vim') |
2551 source Xvim9for.vim | 2551 source Xvim9for.vim |
2552 delete('Xvim9for.vim') | 2552 delete('Xvim9for.vim') |
2553 enddef | 2553 enddef |
2554 | 2554 |
2555 def Test_for_skipped_block() | |
2556 # test skipped blocks at outside of function | |
2557 var lines =<< trim END | |
2558 var result = [] | |
2559 if true | |
2560 for n in [1, 2] | |
2561 result += [n] | |
2562 endfor | |
2563 else | |
2564 for n in [3, 4] | |
2565 result += [n] | |
2566 endfor | |
2567 endif | |
2568 assert_equal([1, 2], result) | |
2569 | |
2570 result = [] | |
2571 if false | |
2572 for n in [1, 2] | |
2573 result += [n] | |
2574 endfor | |
2575 else | |
2576 for n in [3, 4] | |
2577 result += [n] | |
2578 endfor | |
2579 endif | |
2580 assert_equal([3, 4], result) | |
2581 END | |
2582 CheckDefAndScriptSuccess(lines) | |
2583 | |
2584 # test skipped blocks at inside of function | |
2585 lines =<< trim END | |
2586 def DefTrue() | |
2587 var result = [] | |
2588 if true | |
2589 for n in [1, 2] | |
2590 result += [n] | |
2591 endfor | |
2592 else | |
2593 for n in [3, 4] | |
2594 result += [n] | |
2595 endfor | |
2596 endif | |
2597 assert_equal([1, 2], result) | |
2598 enddef | |
2599 DefTrue() | |
2600 | |
2601 def DefFalse() | |
2602 var result = [] | |
2603 if false | |
2604 for n in [1, 2] | |
2605 result += [n] | |
2606 endfor | |
2607 else | |
2608 for n in [3, 4] | |
2609 result += [n] | |
2610 endfor | |
2611 endif | |
2612 assert_equal([3, 4], result) | |
2613 enddef | |
2614 DefFalse() | |
2615 END | |
2616 CheckDefAndScriptSuccess(lines) | |
2617 enddef | |
2618 | |
2555 def Test_for_loop() | 2619 def Test_for_loop() |
2556 var lines =<< trim END | 2620 var lines =<< trim END |
2557 var result = '' | 2621 var result = '' |
2558 for cnt in range(7) | 2622 for cnt in range(7) |
2559 if cnt == 4 | 2623 if cnt == 4 |