}
break;
}
+ case VAR_VOID:
+ emsg(_(e_cannot_use_void_value));
+ break;
case VAR_UNKNOWN:
case VAR_ANY:
- case VAR_VOID:
internal_error_no_abort("f_type(UNKNOWN)");
n = -1;
break;
}
}
}
- copy_tv(tv, rettv);
+ ret = copy_tv(tv, rettv);
}
}
char_u *tv_get_string_buf_chk_strict(typval_T *varp, char_u *buf, int strict);
char_u *tv_stringify(typval_T *varp, char_u *buf);
int tv_check_lock(typval_T *tv, char_u *name, int use_gettext);
-void copy_tv(typval_T *from, typval_T *to);
+int copy_tv(typval_T *from, typval_T *to);
int typval_compare2(typval_T *tv1, typval_T *tv2, exprtype_T type, int ic, int *res);
int typval_compare(typval_T *tv1, typval_T *tv2, exprtype_T type, int ic);
int typval_compare_list(typval_T *tv1, typval_T *tv2, exprtype_T type, int ic, int *res);
unlet g:TestDict
enddef
+" Test for using the type() function with void
+def Test_type_func_with_void()
+ var lines =<< trim END
+ vim9script
+ def GetVoidValue(): void
+ enddef
+ echo type(GetVoidValue())
+ END
+ v9.CheckSourceFailure(lines, 'E1031: Cannot use void value', 4)
+enddef
+
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new
endif
call assert_equal(v:t_blob, type(test_null_blob()))
- call assert_fails("call type(test_void())", ['E340:', 'E685:'])
+ call assert_fails("call type(test_void())", ['E1031: Cannot use void value', 'E1031: Cannot use void value'])
call assert_fails("call type(test_unknown())", ['E340:', 'E685:'])
call assert_equal(0, 0 + v:false)
call assert_true(empty(v:null))
call assert_true(empty(v:none))
+ def s:GetVoidValue(): void
+ enddef
+ call assert_fails('let x = type(s:GetVoidValue())', 'E1031: Cannot use void value')
+
func ChangeYourMind()
try
return v:true
* It is OK for "from" and "to" to point to the same item. This is used to
* make a copy later.
*/
- void
+ int
copy_tv(typval_T *from, typval_T *to)
{
+ int ret = OK;
+
to->v_type = from->v_type;
to->v_lock = 0;
switch (from->v_type)
break;
case VAR_VOID:
emsg(_(e_cannot_use_void_value));
+ ret = FAIL;
break;
case VAR_UNKNOWN:
case VAR_ANY:
internal_error_no_abort("copy_tv(UNKNOWN)");
+ ret = FAIL;
break;
}
+
+ return ret;
}
/*
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1791,
/**/
1790,
/**/