forked from aniani/vim
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Problem: Vim9: key type that can be used for literal dict and indexing is inconsistent. Solution: Allow using number and bool as key for a literal dict. (#7771)
This commit is contained in:
20
src/eval.c
20
src/eval.c
@@ -3849,11 +3849,23 @@ eval_index(
|
||||
clear_tv(&var1);
|
||||
return FAIL;
|
||||
}
|
||||
else if (evaluate && tv_get_string_chk(&var1) == NULL)
|
||||
else if (evaluate)
|
||||
{
|
||||
// not a number or string
|
||||
clear_tv(&var1);
|
||||
return FAIL;
|
||||
#ifdef FEAT_FLOAT
|
||||
// allow for indexing with float
|
||||
if (vim9 && rettv->v_type == VAR_DICT
|
||||
&& var1.v_type == VAR_FLOAT)
|
||||
{
|
||||
var1.vval.v_string = typval_tostring(&var1, TRUE);
|
||||
var1.v_type = VAR_STRING;
|
||||
}
|
||||
#endif
|
||||
if (tv_get_string_chk(&var1) == NULL)
|
||||
{
|
||||
// not a number or string
|
||||
clear_tv(&var1);
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user