File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -217,22 +217,47 @@ def Test_nested_function()
217217 CheckDefFailure ([' def s:Nested()' , ' enddef' ], ' E1075:' )
218218 CheckDefFailure ([' def b:Nested()' , ' enddef' ], ' E1075:' )
219219
220- CheckDefFailure ([
221- ' def Outer()' ,
222- ' def Inner()' ,
223- ' # comment' ,
224- ' enddef' ,
225- ' def Inner()' ,
226- ' enddef' ,
227- ' enddef' ], ' E1073:' )
228- CheckDefFailure ([
229- ' def Outer()' ,
230- ' def Inner()' ,
231- ' # comment' ,
232- ' enddef' ,
233- ' def! Inner()' ,
234- ' enddef' ,
235- ' enddef' ], ' E1117:' )
220+ var lines = << trim END
221+ def Outer ()
222+ def Inner ()
223+ # comment
224+ enddef
225+ def Inner ()
226+ enddef
227+ enddef
228+ END
229+ CheckDefFailure (lines , ' E1073:' )
230+
231+ lines = << trim END
232+ def Outer ()
233+ def Inner ()
234+ # comment
235+ enddef
236+ def ! Inner ()
237+ enddef
238+ enddef
239+ END
240+ CheckDefFailure (lines , ' E1117:' )
241+
242+ # nested function inside conditional
243+ # TODO : should it work when " thecount" is inside the " if" ?
244+ lines = << trim END
245+ vim9script
246+ var thecount = 0
247+ if true
248+ def Test (): number
249+ def TheFunc (): number
250+ thecount += 1
251+ return thecount
252+ enddef
253+ return TheFunc ()
254+ enddef
255+ endif
256+ defcompile
257+ assert_equal (1 , Test ())
258+ assert_equal (2 , Test ())
259+ END
260+ CheckScriptSuccess (lines )
236261enddef
237262
238263func Test_call_default_args_from_func ()
@@ -315,6 +340,15 @@ def Test_nested_def_list()
315340 assert_true (funcs- >index (' def DefListAll()' ) >= 0 )
316341 assert_true (funcs- >index (' def DefListOne()' ) >= 0 )
317342 assert_true (funcs- >index (' def DefListMatches()' ) >= 0 )
343+
344+ var lines = << trim END
345+ vim9script
346+ def Func ()
347+ def + Func+
348+ enddef
349+ defcompile
350+ END
351+ CheckScriptFailure (lines , ' E476:' , 1 )
318352enddef
319353
320354def Test_global_local_function ()
Original file line number Diff line number Diff line change @@ -750,6 +750,8 @@ static char *(features[]) =
750750
751751static int included_patches [] =
752752{ /* Add new patch number below this line */
753+ /**/
754+ 2102 ,
753755/**/
754756 2101 ,
755757/**/
You can’t perform that action at this time.
0 commit comments