CheckScriptSuccess(lines)
enddef
+def Test_not_nested_function()
+ echo printf('%d',
+ function('len')('xxx'))
+enddef
+
func Test_call_default_args_from_func()
call MyDefaultArgs()->assert_equal('string')
call MyDefaultArgs('one')->assert_equal('one')
}
}
+/*
+ * Check if "*cmd" points to a function command and if so advance "*cmd" and
+ * return TRUE.
+ * Otherwise return FALSE;
+ * Do not consider "function(" to be a command.
+ */
+ static int
+is_function_cmd(char_u **cmd)
+{
+ char_u *p = *cmd;
+
+ if (checkforcmd(&p, "function", 2))
+ {
+ if (*p == '(')
+ return FALSE;
+ *cmd = p;
+ return TRUE;
+ }
+ return FALSE;
+}
+
/*
* ":function" also supporting nested ":def".
* When "name_arg" is not NULL this is a nested function, using "name_arg" for
// Only recognize "def" inside "def", not inside "function",
// For backwards compatibility, see Test_function_python().
c = *p;
- if (checkforcmd(&p, "function", 2)
+ if (is_function_cmd(&p)
|| (eap->cmdidx == CMD_def && checkforcmd(&p, "def", 3)))
{
if (*p == '!')