arg_float_or_nr(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_FLOAT || type->tt_type == VAR_NUMBER)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_FLOAT
+ || type->tt_type == VAR_NUMBER)
return OK;
arg_type_mismatch(&t_number, type, context->arg_idx + 1);
return FAIL;
arg_list_or_blob(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_LIST || type->tt_type == VAR_BLOB)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_LIST
+ || type->tt_type == VAR_BLOB)
return OK;
arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
return FAIL;
arg_string_or_nr(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_STRING || type->tt_type == VAR_NUMBER)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_STRING
+ || type->tt_type == VAR_NUMBER)
return OK;
arg_type_mismatch(&t_string, type, context->arg_idx + 1);
return FAIL;
arg_buffer(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_STRING || type->tt_type == VAR_NUMBER)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_STRING
+ || type->tt_type == VAR_NUMBER)
return OK;
arg_type_mismatch(&t_string, type, context->arg_idx + 1);
return FAIL;
arg_buffer_or_dict_any(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_UNKNOWN
|| type->tt_type == VAR_STRING
|| type->tt_type == VAR_NUMBER
|| type->tt_type == VAR_DICT)
arg_lnum(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_STRING || type->tt_type == VAR_NUMBER)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_STRING
+ || type->tt_type == VAR_NUMBER)
return OK;
arg_type_mismatch(&t_string, type, context->arg_idx + 1);
return FAIL;
static int
arg_string_or_list_string(type_T *type, argcontext_T *context)
{
- if (type->tt_type == VAR_ANY || type->tt_type == VAR_STRING)
+ if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_STRING)
return OK;
if (type->tt_type != VAR_LIST)
{
arg_string_or_list_any(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_STRING || type->tt_type == VAR_LIST)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_STRING
+ || type->tt_type == VAR_LIST)
return OK;
arg_type_mismatch(&t_string, type, context->arg_idx + 1);
return FAIL;
arg_string_or_blob(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_STRING || type->tt_type == VAR_BLOB)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_STRING
+ || type->tt_type == VAR_BLOB)
return OK;
arg_type_mismatch(&t_string, type, context->arg_idx + 1);
return FAIL;
arg_list_or_dict(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_LIST || type->tt_type == VAR_DICT)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_LIST
+ || type->tt_type == VAR_DICT)
return OK;
arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
return FAIL;
arg_list_or_dict_or_blob(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_LIST
- || type->tt_type == VAR_DICT
- || type->tt_type == VAR_BLOB)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_LIST
+ || type->tt_type == VAR_DICT
+ || type->tt_type == VAR_BLOB)
return OK;
arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
return FAIL;
arg_list_or_dict_or_blob_or_string(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_LIST
- || type->tt_type == VAR_DICT
- || type->tt_type == VAR_BLOB
- || type->tt_type == VAR_STRING)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_LIST
+ || type->tt_type == VAR_DICT
+ || type->tt_type == VAR_BLOB
+ || type->tt_type == VAR_STRING)
return OK;
arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
return FAIL;
arg_string_list_or_blob(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_LIST
- || type->tt_type == VAR_BLOB
- || type->tt_type == VAR_STRING)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_LIST
+ || type->tt_type == VAR_BLOB
+ || type->tt_type == VAR_STRING)
return OK;
arg_type_mismatch(&t_list_any, type, context->arg_idx + 1);
return FAIL;
arg_chan_or_job(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_UNKNOWN
|| type->tt_type == VAR_CHANNEL
|| type->tt_type == VAR_JOB)
return OK;
arg_str_or_nr_or_list(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_STRING
- || type->tt_type == VAR_NUMBER
- || type->tt_type == VAR_LIST)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_STRING
+ || type->tt_type == VAR_NUMBER
+ || type->tt_type == VAR_LIST)
return OK;
arg_type_mismatch(&t_string, type, context->arg_idx + 1);
return FAIL;
arg_dict_any_or_string(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
- || type->tt_type == VAR_DICT
- || type->tt_type == VAR_STRING)
+ || type->tt_type == VAR_UNKNOWN
+ || type->tt_type == VAR_DICT
+ || type->tt_type == VAR_STRING)
return OK;
arg_type_mismatch(&t_string, type, context->arg_idx + 1);
return FAIL;
arg_get1(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_UNKNOWN
|| type->tt_type == VAR_BLOB
|| type->tt_type == VAR_LIST
|| type->tt_type == VAR_DICT
arg_len1(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_UNKNOWN
|| type->tt_type == VAR_STRING
|| type->tt_type == VAR_NUMBER
|| type->tt_type == VAR_BLOB
arg_repeat1(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_UNKNOWN
|| type->tt_type == VAR_STRING
|| type->tt_type == VAR_NUMBER
|| type->tt_type == VAR_LIST)
arg_slice1(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_UNKNOWN
|| type->tt_type == VAR_LIST
|| type->tt_type == VAR_BLOB
|| type->tt_type == VAR_STRING)
arg_count1(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_UNKNOWN
|| type->tt_type == VAR_STRING
|| type->tt_type == VAR_LIST
|| type->tt_type == VAR_DICT)
arg_cursor1(type_T *type, argcontext_T *context)
{
if (type->tt_type == VAR_ANY
+ || type->tt_type == VAR_UNKNOWN
|| type->tt_type == VAR_NUMBER
|| type->tt_type == VAR_STRING
|| type->tt_type == VAR_LIST)
vartype = (*typep)->tt_type;
idxtype = ((type_T **)stack->ga_data)[stack->ga_len - 1];
// If the index is a string, the variable must be a Dict.
- if (*typep == &t_any && idxtype == &t_string)
+ if ((*typep == &t_any || *typep == &t_unknown) && idxtype == &t_string)
vartype = VAR_DICT;
if (vartype == VAR_STRING || vartype == VAR_LIST || vartype == VAR_BLOB)
{
return FAIL;
}
}
- else if (vartype == VAR_LIST || *typep == &t_any)
+ else if (vartype == VAR_LIST || *typep == &t_any || *typep == &t_unknown)
{
if (is_slice)
{
// Global, Buffer-local, Window-local and Tabpage-local
// variables can be defined later, thus we don't check if it
// exists, give an error at runtime.
- res = generate_LOAD(cctx, isn_type, 0, name, &t_any);
+ res = generate_LOAD(cctx, isn_type, 0, name, &t_unknown);
}
}
}
if (type == &t_bool)
return OK;
- if (type == &t_any || type == &t_number || type == &t_number_bool)
+ if (type == &t_any
+ || type == &t_unknown
+ || type == &t_number
+ || type == &t_number_bool)
// Number 0 and 1 are OK to use as a bool. "any" could also be a bool.
// This requires a runtime type check.
return generate_COND2BOOL(cctx);
generate_ppconst(cctx, ppconst);
actual = ((type_T **)stack->ga_data)[stack->ga_len - 1];
- if (check_type(want_type, actual, FALSE, where) == FAIL)
+ if (check_type_maybe(want_type, actual, FALSE, where) != OK)
{
- if (need_type(actual, want_type, -1, 0, cctx, FALSE, FALSE) == FAIL)
+ if (need_type(actual, want_type, -1, 0, cctx, FALSE, FALSE)
+ == FAIL)
return FAIL;
}
}