Skip to content
Snippets Groups Projects
Commit c66f645b authored by Bram Moolenaar's avatar Bram Moolenaar
Browse files

patch 8.2.3359: Vim9: error for type when variable is not set

Problem:    Vim9: error for type when variable is not set.
Solution:   Give a specific error for a NULL function. (closes #8773)
parent dea56111
No related branches found
No related tags found
No related merge requests found
...@@ -652,3 +652,5 @@ EXTERN char e_exists_compiled_can_only_be_used_in_def_function[] ...@@ -652,3 +652,5 @@ EXTERN char e_exists_compiled_can_only_be_used_in_def_function[]
INIT(= N_("E1233: exists_compiled() can only be used in a :def function")); INIT(= N_("E1233: exists_compiled() can only be used in a :def function"));
EXTERN char e_legacy_must_be_followed_by_command[] EXTERN char e_legacy_must_be_followed_by_command[]
INIT(= N_("E1234: legacy must be followed by a command")); INIT(= N_("E1234: legacy must be followed by a command"));
EXTERN char e_function_reference_is_not_set[]
INIT(= N_("E1235: Function reference is not set"));
...@@ -2696,6 +2696,15 @@ def Test_partial_call() ...@@ -2696,6 +2696,15 @@ def Test_partial_call()
assert_equal('ooooo', RepeatFunc(5)) assert_equal('ooooo', RepeatFunc(5))
END END
CheckDefAndScriptSuccess(lines) CheckDefAndScriptSuccess(lines)
lines =<< trim END
vim9script
def Foo(Parser: any)
enddef
var Expr: func(dict<any>): dict<any>
const Call = Foo(Expr)
END
CheckScriptFailure(lines, 'E1235:')
enddef enddef
def Test_cmd_modifier() def Test_cmd_modifier()
......
...@@ -755,6 +755,8 @@ static char *(features[]) = ...@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3359,
/**/ /**/
3358, 3358,
/**/ /**/
......
...@@ -461,6 +461,16 @@ check_typval_type(type_T *expected, typval_T *actual_tv, where_T where) ...@@ -461,6 +461,16 @@ check_typval_type(type_T *expected, typval_T *actual_tv, where_T where)
type_T *actual_type; type_T *actual_type;
int res = FAIL; int res = FAIL;
// For some values there is no type, assume an error will be given later
// for an invalid value.
if ((actual_tv->v_type == VAR_FUNC && actual_tv->vval.v_string == NULL)
|| (actual_tv->v_type == VAR_PARTIAL
&& actual_tv->vval.v_partial == NULL))
{
emsg(_(e_function_reference_is_not_set));
return FAIL;
}
ga_init2(&type_list, sizeof(type_T *), 10); ga_init2(&type_list, sizeof(type_T *), 10);
actual_type = typval2type(actual_tv, get_copyID(), &type_list, TRUE); actual_type = typval2type(actual_tv, get_copyID(), &type_list, TRUE);
if (actual_type != NULL) if (actual_type != NULL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment