1
0
forked from aniani/vim

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 #6270)
This commit is contained in:
Bram Moolenaar
2020-06-18 20:50:10 +02:00
parent 9b68c82b7c
commit efd8855594
4 changed files with 130 additions and 33 deletions

View File

@@ -31,6 +31,31 @@ def Test_return_something()
assert_fails('call ReturnGlobal()', 'E1029: Expected number but got string')
enddef
def Test_missing_return()
CheckDefFailure(['def Missing(): number',
' if g:cond',
' echo "no return"',
' else',
' return 0',
' endif'
'enddef'], 'E1027:')
CheckDefFailure(['def Missing(): number',
' if g:cond',
' return 1',
' else',
' echo "no return"',
' endif'
'enddef'], 'E1027:')
CheckDefFailure(['def Missing(): number',
' if g:cond',
' return 1',
' else',
' return 2',
' endif'
' return 3'
'enddef'], 'E1095:')
enddef
let s:nothing = 0
def ReturnNothing()
s:nothing = 1