summaryrefslogtreecommitdiffstats
path: root/src/evalfunc.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-21 12:32:17 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-21 12:32:17 +0000
commit59618fed4ce118d12686c2e5c7c09601c8177817 (patch)
tree452cda2940d810a2b346826c09b8bd6c23952c6e /src/evalfunc.c
parent0d807107b66e0d30d4f338c272962af5714c400e (diff)
patch 8.2.3866: Vim9: type checking global variables is inconsistentv8.2.3866
Problem: Vim9: type checking global variables is inconsistent. Solution: Use the "unknown" type in more places.
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r--src/evalfunc.c79
1 files changed, 55 insertions, 24 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c
index d8c621d54b..39b94deb97 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -228,7 +228,9 @@ check_arg_type(
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;
@@ -313,7 +315,9 @@ arg_bool(type_T *type, argcontext_T *context)
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;
@@ -326,7 +330,9 @@ arg_list_or_blob(type_T *type, argcontext_T *context)
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;
@@ -339,7 +345,9 @@ arg_string_or_nr(type_T *type, argcontext_T *context)
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;
@@ -352,6 +360,7 @@ arg_buffer(type_T *type, argcontext_T *context)
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)
@@ -367,7 +376,9 @@ arg_buffer_or_dict_any(type_T *type, argcontext_T *context)
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;
@@ -379,7 +390,9 @@ arg_lnum(type_T *type, argcontext_T *context)
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)
{
@@ -401,7 +414,9 @@ arg_string_or_list_string(type_T *type, argcontext_T *context)
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;
@@ -414,7 +429,9 @@ arg_string_or_list_any(type_T *type, argcontext_T *context)
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;
@@ -427,7 +444,9 @@ arg_string_or_blob(type_T *type, argcontext_T *context)
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;
@@ -440,9 +459,10 @@ arg_list_or_dict(type_T *type, argcontext_T *context)
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;
@@ -455,10 +475,11 @@ arg_list_or_dict_or_blob(type_T *type, argcontext_T *context)
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;
@@ -471,9 +492,10 @@ arg_list_or_dict_or_blob_or_string(type_T *type, argcontext_T *context)
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;
@@ -495,6 +517,7 @@ arg_job(type_T *type, argcontext_T *context)
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;
@@ -557,9 +580,10 @@ arg_item_of_prev(type_T *type, argcontext_T *context)
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;
@@ -572,8 +596,9 @@ arg_str_or_nr_or_list(type_T *type, argcontext_T *context)
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;
@@ -603,6 +628,7 @@ arg_extend3(type_T *type, argcontext_T *context)
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
@@ -622,6 +648,7 @@ arg_get1(type_T *type, argcontext_T *context)
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
@@ -657,6 +684,7 @@ arg_remove2(type_T *type, argcontext_T *context)
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)
@@ -674,6 +702,7 @@ arg_repeat1(type_T *type, argcontext_T *context)
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)
@@ -691,6 +720,7 @@ arg_slice1(type_T *type, argcontext_T *context)
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)
@@ -708,6 +738,7 @@ arg_count1(type_T *type, argcontext_T *context)
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)