comparison src/testdir/test_vim9_expr.vim @ 24645:668df21d8bc6 v8.2.2861

patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement Commit: https://github.com/vim/vim/commit/3b1373b193ce5fbf25e852277a4ecc98688c7bb8 Author: Bram Moolenaar <Bram@vim.org> Date: Mon May 17 00:01:42 2021 +0200 patch 8.2.2861: Vim9: "legacy return" is not recognized as a return statement Problem: Vim9: "legacy return" is not recognized as a return statement. Solution: Specifically check for a return command. (closes https://github.com/vim/vim/issues/8213)
author Bram Moolenaar <Bram@vim.org>
date Mon, 17 May 2021 00:15:03 +0200
parents 033b43570140
children 04205b7d67d5
comparison
equal deleted inserted replaced
24644:20eabe0f4d72 24645:668df21d8bc6
2775 echo + +n 2775 echo + +n
2776 END 2776 END
2777 CheckDefAndScriptFailure(lines, 'E15:') 2777 CheckDefAndScriptFailure(lines, 'E15:')
2778 enddef 2778 enddef
2779 2779
2780 def LegacyReturn(): string
2781 legacy return #{key: 'ok'}.key
2782 enddef
2783
2780 def Test_expr7_legacy_script() 2784 def Test_expr7_legacy_script()
2781 var lines =<< trim END 2785 var lines =<< trim END
2782 let s:legacy = 'legacy' 2786 let s:legacy = 'legacy'
2783 def GetLocal(): string 2787 def GetLocal(): string
2784 return legacy 2788 return legacy
2788 enddef 2792 enddef
2789 call assert_equal('legacy', GetLocal()) 2793 call assert_equal('legacy', GetLocal())
2790 call assert_equal('legacy', GetLocalPrefix()) 2794 call assert_equal('legacy', GetLocalPrefix())
2791 END 2795 END
2792 CheckScriptSuccess(lines) 2796 CheckScriptSuccess(lines)
2797
2798 assert_equal('ok', LegacyReturn())
2799
2800 lines =<< trim END
2801 vim9script
2802 def GetNumber(): number
2803 legacy return range(3)->map('v:val + 1')
2804 enddef
2805 echo GetNumber()
2806 END
2807 CheckScriptFailure(lines, 'E1012: Type mismatch; expected number but got list<number>')
2793 enddef 2808 enddef
2794 2809
2795 def Echo(arg: any): string 2810 def Echo(arg: any): string
2796 return arg 2811 return arg
2797 enddef 2812 enddef