mirror of
https://github.com/neovim/neovim.git
synced 2025-10-04 17:06:30 +00:00
vim-patch:8.1.1692: using *{} for literal dict is not backwards compatible
Problem: Using *{} for literal dict is not backwards compatible. (Yasuhiro
Matsumoto)
Solution: Use ~{} instead.
b8be54dcc5
This commit is contained in:
@@ -3802,7 +3802,7 @@ static int eval6(char_u **arg, typval_T *rettv, int evaluate, int want_string)
|
||||
*/
|
||||
for (;; ) {
|
||||
op = **arg;
|
||||
if ((op != '*' || (*arg)[1] == '{') && op != '/' && op != '%') {
|
||||
if (op != '*' && op != '/' && op != '%') {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3906,7 +3906,7 @@ static int eval6(char_u **arg, typval_T *rettv, int evaluate, int want_string)
|
||||
// (expression) nested expression
|
||||
// [expr, expr] List
|
||||
// {key: val, key: val} Dictionary
|
||||
// *{key: val, key: val} Dictionary with literal keys
|
||||
// ~{key: val, key: val} Dictionary with literal keys
|
||||
//
|
||||
// Also handle:
|
||||
// ! in front logical NOT
|
||||
@@ -4014,8 +4014,8 @@ static int eval7(
|
||||
case '[': ret = get_list_tv(arg, rettv, evaluate);
|
||||
break;
|
||||
|
||||
// Dictionary: *{key: val, key: val}
|
||||
case '*':
|
||||
// Dictionary: ~{key: val, key: val}
|
||||
case '~':
|
||||
if ((*arg)[1] == '{') {
|
||||
(*arg)++;
|
||||
ret = dict_get_tv(arg, rettv, evaluate, true);
|
||||
|
@@ -281,8 +281,11 @@ func Test_dict_func_remove_in_use()
|
||||
endfunc
|
||||
|
||||
func Test_dict_literal_keys()
|
||||
call assert_equal({'one': 1, 'two2': 2, '3three': 3, '44': 4}, *{one: 1, two2: 2, 3three: 3, 44: 4},)
|
||||
call assert_equal('2 3', trim(execute('echo 2 *{blue: 3}.blue')))
|
||||
call assert_equal({'one': 1, 'two2': 2, '3three': 3, '44': 4}, ~{one: 1, two2: 2, 3three: 3, 44: 4},)
|
||||
|
||||
" why *{} cannot be used
|
||||
let blue = 'blue'
|
||||
call assert_equal('6', trim(execute('echo 2 *{blue: 3}.blue')))
|
||||
endfunc
|
||||
|
||||
" Nasty: deepcopy() dict that refers to itself (fails when noref used)
|
||||
|
Reference in New Issue
Block a user