mirror of
https://github.com/vim/vim.git
synced 2025-09-25 03:54:15 -04:00
patch 8.2.1337: Vim9: cannot use empty key in dict assignment
Problem: Vim9: cannot use empty key in dict assignment. Solution: Allow empty key. (closes #6591)
This commit is contained in:
@@ -244,7 +244,10 @@ def Test_assignment_dict()
|
|||||||
# overwrite
|
# overwrite
|
||||||
dict3['key'] = 'another'
|
dict3['key'] = 'another'
|
||||||
|
|
||||||
call CheckDefExecFailure(['let dd = {}', 'dd[""] = 6'], 'E713:')
|
# empty key can be used
|
||||||
|
let dd = {}
|
||||||
|
dd[""] = 6
|
||||||
|
assert_equal({'': 6}, dd)
|
||||||
|
|
||||||
# type becomes dict<any>
|
# type becomes dict<any>
|
||||||
let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
|
let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'}
|
||||||
@@ -783,13 +786,6 @@ def Test_try_catch()
|
|||||||
endtry
|
endtry
|
||||||
assert_equal(300, n)
|
assert_equal(300, n)
|
||||||
|
|
||||||
try
|
|
||||||
d[''] = 3
|
|
||||||
catch /E713:/
|
|
||||||
n = 311
|
|
||||||
endtry
|
|
||||||
assert_equal(311, n)
|
|
||||||
|
|
||||||
try
|
try
|
||||||
unlet g:does_not_exist
|
unlet g:does_not_exist
|
||||||
catch /E108:/
|
catch /E108:/
|
||||||
|
@@ -754,6 +754,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 */
|
||||||
|
/**/
|
||||||
|
1337,
|
||||||
/**/
|
/**/
|
||||||
1336,
|
1336,
|
||||||
/**/
|
/**/
|
||||||
|
@@ -1422,11 +1422,8 @@ call_def_function(
|
|||||||
dict_T *dict = tv_dict->vval.v_dict;
|
dict_T *dict = tv_dict->vval.v_dict;
|
||||||
dictitem_T *di;
|
dictitem_T *di;
|
||||||
|
|
||||||
if (key == NULL || *key == NUL)
|
if (key == NULL)
|
||||||
{
|
key = (char_u *)"";
|
||||||
emsg(_(e_emptykey));
|
|
||||||
goto on_error;
|
|
||||||
}
|
|
||||||
tv = STACK_TV_BOT(-3);
|
tv = STACK_TV_BOT(-3);
|
||||||
di = dict_find(dict, key, -1);
|
di = dict_find(dict, key, -1);
|
||||||
if (di != NULL)
|
if (di != NULL)
|
||||||
|
Reference in New Issue
Block a user