Patch 8.2.2645
Problem: Using inline function is not properly tested.
Solution: Add test cases, esp. for errors. Minor code improvements.
Files: src/userfunc.c, src/errors.h, src/testdir/test_vim9_expr.vim,
src/testdir/test_vim9_func.vim
*** ../vim-8.2.2644/src/userfunc.c 2021-03-22 18:22:24.626891593 +0100
--- src/userfunc.c 2021-03-22 20:43:16.400502719 +0100
***************
*** 731,743 ****
else if (line_arg != NULL && *skipwhite(line_arg) != NUL)
nextcmd = line_arg;
else if (*p != NUL && *p != (vim9_function ? '#' : '"')
! && p_verbose > 0
! && eap->cmdidx != CMD_block)
! give_warning2(eap->cmdidx == CMD_def
! ? (char_u *)_("W1001: Text found after :enddef: %s")
! : (char_u *)_("W22: Text found after :endfunction:
%s"),
! p, TRUE);
! if (nextcmd != NULL)
{
// Another command follows. If the line came from "eap"
// we can simply point into it, otherwise we need to
--- 731,746 ----
else if (line_arg != NULL && *skipwhite(line_arg) != NUL)
nextcmd = line_arg;
else if (*p != NUL && *p != (vim9_function ? '#' : '"')
! && (vim9_function || p_verbose > 0))
! {
! if (eap->cmdidx == CMD_def)
! semsg(_(e_text_found_after_enddef_str), p);
! else
! give_warning2((char_u *)
! _("W22: Text found after :endfunction: %s"),
! p, TRUE);
! }
! if (nextcmd != NULL && *skipwhite(nextcmd) != NUL)
{
// Another command follows. If the line came from "eap"
// we can simply point into it, otherwise we need to
*** ../vim-8.2.2644/src/errors.h 2021-03-21 20:53:24.926400996 +0100
--- src/errors.h 2021-03-22 20:38:21.348968818 +0100
***************
*** 381,383 ****
--- 381,385 ----
INIT(= N_("E1171: Missing } after inline function"));
EXTERN char e_cannot_use_default_values_in_lambda[]
INIT(= N_("E1172: Cannot use default values in a lambda"));
+ EXTERN char e_text_found_after_enddef_str[]
+ INIT(= N_("E1173: Text found after enddef: %s"));
*** ../vim-8.2.2644/src/testdir/test_vim9_expr.vim 2021-03-22
18:22:24.626891593 +0100
--- src/testdir/test_vim9_expr.vim 2021-03-22 20:32:54.485695994 +0100
***************
*** 1961,1966 ****
--- 1961,1971 ----
return 'no'
})
assert_equal(['no', 'yes', 'no'], dll)
+
+ sandbox var Safe = (nr: number): number => {
+ return nr + 7
+ }
+ assert_equal(10, Safe(3))
END
CheckDefAndScriptSuccess(lines)
***************
*** 1968,1973 ****
--- 1973,2006 ----
map([1, 2], (k, v) => { redrawt })
END
CheckDefAndScriptFailure(lines, 'E488')
+
+ lines =<< trim END
+ var Func = (nr: int) => {
+ echo nr
+ }
+ END
+ CheckDefAndScriptFailure(lines, 'E1010', 1)
+
+ lines =<< trim END
+ var Func = (nr: number): int => {
+ return nr
+ }
+ END
+ CheckDefAndScriptFailure(lines, 'E1010', 1)
+
+ lines =<< trim END
+ var Func = (nr: number): int => {
+ return nr
+ END
+ CheckDefAndScriptFailure(lines, 'E1171', 1) # line nr is function start
+
+ lines =<< trim END
+ vim9script
+ var Func = (nr: number): int => {
+ var ll =<< ENDIT
+ nothing
+ END
+ CheckScriptFailure(lines, 'E1145: Missing heredoc end marker: ENDIT', 2)
enddef
def NewLambdaWithComments(): func
*** ../vim-8.2.2644/src/testdir/test_vim9_func.vim 2021-03-17
21:29:25.497532653 +0100
--- src/testdir/test_vim9_func.vim 2021-03-22 20:47:31.656131826 +0100
***************
*** 86,91 ****
--- 86,101 ----
enddef
END
CheckScriptFailure(lines, 'E1152:', 4)
+
+ lines =<< trim END
+ def Ok()
+ echo 'hello'
+ enddef | echo 'there'
+ def Bad()
+ echo 'hello'
+ enddef there
+ END
+ CheckScriptFailure(lines, 'E1173: Text found after enddef: there', 6)
enddef
def Test_missing_endfunc_enddef()
*** ../vim-8.2.2644/src/version.c 2021-03-22 19:43:30.352211669 +0100
--- src/version.c 2021-03-22 20:48:14.484063169 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2645,
/**/
--
When a fly lands on the ceiling, does it do a half roll or
a half loop?
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/202103221949.12MJnkpJ2424655%40masaka.moolenaar.net.