Mercurial > vim
comparison src/testdir/test_vim9_disassemble.vim @ 22860:53acb89ec9f2 v8.2.1977
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Commit: https://github.com/vim/vim/commit/ea2d407f9c144bb634c59017944e4930ed7f80a2
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Nov 12 12:08:51 2020 +0100
patch 8.2.1977: Vim9: error for using a string in a condition is confusing
Problem: Vim9: error for using a string in a condition is confusing.
Solution: Give a more specific error. Also adjust the compile time type
checking for || and &&.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 12 Nov 2020 12:15:04 +0100 |
parents | f2fbbb72ff28 |
children | edfbb06cd0ee |
comparison
equal
deleted
inserted
replaced
22859:757858b35433 | 22860:53acb89ec9f2 |
---|---|
705 # GUI not running but can start later, call has() | 705 # GUI not running but can start later, call has() |
706 instr_expected = 'HasGuiRunning.*' .. | 706 instr_expected = 'HasGuiRunning.*' .. |
707 'if has("gui_running")\_s*' .. | 707 'if has("gui_running")\_s*' .. |
708 '\d PUSHS "gui_running"\_s*' .. | 708 '\d PUSHS "gui_running"\_s*' .. |
709 '\d BCALL has(argc 1)\_s*' .. | 709 '\d BCALL has(argc 1)\_s*' .. |
710 '\d COND2BOOL\_s*' .. | |
710 '\d JUMP_IF_FALSE -> \d\_s*' .. | 711 '\d JUMP_IF_FALSE -> \d\_s*' .. |
711 ' echo "yes"\_s*' .. | 712 ' echo "yes"\_s*' .. |
712 '\d PUSHS "yes"\_s*' .. | 713 '\d PUSHS "yes"\_s*' .. |
713 '\d ECHO 1\_s*' .. | 714 '\d ECHO 1\_s*' .. |
714 'else\_s*' .. | 715 'else\_s*' .. |
758 def Test_disassemble_return_in_if() | 759 def Test_disassemble_return_in_if() |
759 var instr = execute('disassemble ReturnInIf') | 760 var instr = execute('disassemble ReturnInIf') |
760 assert_match('ReturnInIf\_s*' .. | 761 assert_match('ReturnInIf\_s*' .. |
761 'if g:cond\_s*' .. | 762 'if g:cond\_s*' .. |
762 '0 LOADG g:cond\_s*' .. | 763 '0 LOADG g:cond\_s*' .. |
763 '1 JUMP_IF_FALSE -> 4\_s*' .. | 764 '1 COND2BOOL\_s*' .. |
765 '2 JUMP_IF_FALSE -> 5\_s*' .. | |
764 'return "yes"\_s*' .. | 766 'return "yes"\_s*' .. |
765 '2 PUSHS "yes"\_s*' .. | 767 '3 PUSHS "yes"\_s*' .. |
766 '3 RETURN\_s*' .. | 768 '4 RETURN\_s*' .. |
767 'else\_s*' .. | 769 'else\_s*' .. |
768 ' return "no"\_s*' .. | 770 ' return "no"\_s*' .. |
769 '4 PUSHS "no"\_s*' .. | 771 '5 PUSHS "no"\_s*' .. |
770 '5 RETURN$', | 772 '6 RETURN$', |
771 instr) | 773 instr) |
772 enddef | 774 enddef |
773 | 775 |
774 def WithFunc() | 776 def WithFunc() |
775 var Funky1: func | 777 var Funky1: func |
1355 def Test_disassemble_return_bool() | 1357 def Test_disassemble_return_bool() |
1356 var instr = execute('disassemble ReturnBool') | 1358 var instr = execute('disassemble ReturnBool') |
1357 assert_match('ReturnBool\_s*' .. | 1359 assert_match('ReturnBool\_s*' .. |
1358 'var name: bool = 1 && 0 || 1\_s*' .. | 1360 'var name: bool = 1 && 0 || 1\_s*' .. |
1359 '0 PUSHNR 1\_s*' .. | 1361 '0 PUSHNR 1\_s*' .. |
1360 '1 JUMP_IF_COND_FALSE -> 3\_s*' .. | 1362 '1 2BOOL (!!val)\_s*' .. |
1361 '2 PUSHNR 0\_s*' .. | 1363 '2 JUMP_IF_COND_FALSE -> 5\_s*' .. |
1362 '3 COND2BOOL\_s*' .. | 1364 '3 PUSHNR 0\_s*' .. |
1363 '4 JUMP_IF_COND_TRUE -> 6\_s*' .. | 1365 '4 2BOOL (!!val)\_s*' .. |
1364 '5 PUSHNR 1\_s*' .. | 1366 '5 JUMP_IF_COND_TRUE -> 8\_s*' .. |
1365 '6 2BOOL (!!val)\_s*' .. | 1367 '6 PUSHNR 1\_s*' .. |
1368 '7 2BOOL (!!val)\_s*' .. | |
1366 '\d STORE $0\_s*' .. | 1369 '\d STORE $0\_s*' .. |
1367 'return name\_s*' .. | 1370 'return name\_s*' .. |
1368 '\d LOAD $0\_s*' .. | 1371 '\d\+ LOAD $0\_s*' .. |
1369 '\d RETURN', | 1372 '\d\+ RETURN', |
1370 instr) | 1373 instr) |
1371 assert_equal(true, InvertBool()) | 1374 assert_equal(true, InvertBool()) |
1372 enddef | 1375 enddef |
1373 | 1376 |
1374 def Test_disassemble_compare() | 1377 def Test_disassemble_compare() |