comparison src/testdir/test_vim9_disassemble.vim @ 20909:0d7465881b06 v8.2.1006

patch 8.2.1006: Vim9: require unnecessary return statement Commit: https://github.com/vim/vim/commit/efd885559405e1561d577e1b0e6fa827705d285e Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jun 18 20:50:10 2020 +0200 patch 8.2.1006: Vim9: require unnecessary return statement Problem: Vim9: require unnecessary return statement. Solution: Improve the use of the had_return flag. (closes https://github.com/vim/vim/issues/6270)
author Bram Moolenaar <Bram@vim.org>
date Thu, 18 Jun 2020 21:00:04 +0200
parents 489cb75c76b6
children a127db33a075
comparison
equal deleted inserted replaced
20908:4c697217281e 20909:0d7465881b06
531 assert_notmatch('PUSHS "something"', instr) 531 assert_notmatch('PUSHS "something"', instr)
532 assert_notmatch('PUSHS "less"', instr) 532 assert_notmatch('PUSHS "less"', instr)
533 assert_notmatch('JUMP', instr) 533 assert_notmatch('JUMP', instr)
534 enddef 534 enddef
535 535
536 def ReturnInIf(): string
537 if g:cond
538 return "yes"
539 else
540 return "no"
541 endif
542 enddef
543
544 def Test_disassemble_return_in_if()
545 let instr = execute('disassemble ReturnInIf')
546 assert_match('ReturnInIf\_s*' ..
547 'if g:cond\_s*' ..
548 '0 LOADG g:cond\_s*' ..
549 '1 JUMP_IF_FALSE -> 4\_s*' ..
550 'return "yes"\_s*' ..
551 '2 PUSHS "yes"\_s*' ..
552 '3 RETURN\_s*' ..
553 'else\_s*' ..
554 ' return "no"\_s*' ..
555 '4 PUSHS "no"\_s*' ..
556 '5 RETURN$',
557 instr)
558 enddef
559
536 def WithFunc() 560 def WithFunc()
537 let Funky1: func 561 let Funky1: func
538 let Funky2: func = function("len") 562 let Funky2: func = function("len")
539 let Party2: func = funcref("UserFunc") 563 let Party2: func = funcref("UserFunc")
540 enddef 564 enddef