To: vim_dev@googlegroups.com Subject: Patch 8.2.2082 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2082 Problem: Vim9: can still use the depricated #{} dict syntax. Solution: Remove support for #{} in Vim9 script. (closes #7406, closes #7405) Files: src/dict.c, src/proto/dict.pro, src/eval.c, src/vim9compile.c, src/testdir/test_vim9_assign.vim, src/testdir/test_vim9_builtin.vim, src/testdir/test_vim9_cmd.vim, src/testdir/test_vim9_disassemble.vim, src/testdir/test_vim9_expr.vim, src/testdir/test_vim9_func.vim, src/testdir/test_vim9_script.vim, src/testdir/test_popupwin.vim, src/testdir/test_textprop.vim *** ../vim-8.2.2081/src/dict.c 2020-11-19 19:01:39.746594508 +0100 --- src/dict.c 2020-12-02 16:18:41.320027896 +0100 *************** *** 783,801 **** } /* * Get the key for #{key: val} into "tv" and advance "arg". * Return FAIL when there is no valid key. */ static int get_literal_key(char_u **arg, typval_T *tv) { ! char_u *p; ! if (!ASCII_ISALNUM(**arg) && **arg != '_' && **arg != '-') return FAIL; - - for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; ++p) - ; tv->v_type = VAR_STRING; tv->vval.v_string = vim_strnsave(*arg, p - *arg); --- 783,812 ---- } /* + * Advance over a literal key, including "-". If the first character is not a + * literal key character then "key" is returned. + */ + char_u * + skip_literal_key(char_u *key) + { + char_u *p; + + for (p = key; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; ++p) + ; + return p; + } + + /* * Get the key for #{key: val} into "tv" and advance "arg". * Return FAIL when there is no valid key. */ static int get_literal_key(char_u **arg, typval_T *tv) { ! char_u *p = skip_literal_key(*arg); ! if (p == *arg) return FAIL; tv->v_type = VAR_STRING; tv->vval.v_string = vim_strnsave(*arg, p - *arg); *************** *** 851,867 **** *arg = skipwhite_and_linebreak(*arg + 1, evalarg); while (**arg != '}' && **arg != NUL) { ! char_u *p = to_name_end(*arg, FALSE); ! if (literal || (vim9script && *p == ':')) { if (get_literal_key(arg, &tvkey) == FAIL) goto failret; } else { - int has_bracket = vim9script && **arg == '['; - if (has_bracket) *arg = skipwhite(*arg + 1); if (eval1(arg, &tvkey, evalarg) == FAIL) // recursive! --- 862,876 ---- *arg = skipwhite_and_linebreak(*arg + 1, evalarg); while (**arg != '}' && **arg != NUL) { ! int has_bracket = vim9script && **arg == '['; ! if (literal || (vim9script && !has_bracket)) { if (get_literal_key(arg, &tvkey) == FAIL) goto failret; } else { if (has_bracket) *arg = skipwhite(*arg + 1); if (eval1(arg, &tvkey, evalarg) == FAIL) // recursive! *** ../vim-8.2.2081/src/proto/dict.pro 2020-08-18 13:04:10.795215214 +0200 --- src/proto/dict.pro 2020-12-02 16:18:44.524018053 +0100 *************** *** 33,38 **** --- 33,39 ---- varnumber_T dict_get_number_check(dict_T *d, char_u *key); varnumber_T dict_get_bool(dict_T *d, char_u *key, int def); char_u *dict2string(typval_T *tv, int copyID, int restore_copyID); + char_u *skip_literal_key(char_u *key); int eval_dict(char_u **arg, typval_T *rettv, evalarg_T *evalarg, int literal); void dict_extend(dict_T *d1, dict_T *d2, char_u *action); dictitem_T *dict_lookup(hashitem_T *hi); *** ../vim-8.2.2081/src/eval.c 2020-11-28 21:21:13.830682201 +0100 --- src/eval.c 2020-12-02 15:44:20.882148347 +0100 *************** *** 3254,3260 **** /* * Dictionary: #{key: val, key: val} */ ! case '#': if ((*arg)[1] == '{') { ++*arg; ret = eval_dict(arg, rettv, evalarg, TRUE); --- 3254,3260 ---- /* * Dictionary: #{key: val, key: val} */ ! case '#': if (!in_vim9script() && (*arg)[1] == '{') { ++*arg; ret = eval_dict(arg, rettv, evalarg, TRUE); *** ../vim-8.2.2081/src/vim9compile.c 2020-12-02 15:11:14.219994586 +0100 --- src/vim9compile.c 2020-12-02 16:19:14.543925755 +0100 *************** *** 2127,2138 **** } /* ! * Return TRUE if "p" points at a "#" but not at "#{". */ int vim9_comment_start(char_u *p) { ! return p[0] == '#' && p[1] != '{'; } /* --- 2127,2138 ---- } /* ! * Return TRUE if "p" points at a "#". Does not check for white space. */ int vim9_comment_start(char_u *p) { ! return p[0] == '#'; } /* *************** *** 2840,2853 **** if (eval_list(&p, &rettv, NULL, FALSE) == FAIL) p = arg; } - else if (p == arg && *arg == '#' && arg[1] == '{') - { - // Can be "#{a: 1}->Func()". - ++p; - if (eval_dict(&p, &rettv, NULL, TRUE) == FAIL) - p = arg; - } - return p; } --- 2840,2845 ---- *************** *** 2999,3010 **** } /* ! * parse a dict: {'key': val} or #{key: val} * "*arg" points to the '{'. * ppconst->pp_is_const is set if all item values are a constant. */ static int ! compile_dict(char_u **arg, cctx_T *cctx, int literal, ppconst_T *ppconst) { garray_T *instr = &cctx->ctx_instr; garray_T *stack = &cctx->ctx_type_stack; --- 2991,3002 ---- } /* ! * parse a dict: {key: val, [key]: val} * "*arg" points to the '{'. * ppconst->pp_is_const is set if all item values are a constant. */ static int ! compile_dict(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) { garray_T *instr = &cctx->ctx_instr; garray_T *stack = &cctx->ctx_type_stack; *************** *** 3022,3028 **** for (;;) { char_u *key = NULL; - char_u *end; if (may_get_next_line(whitep, arg, cctx) == FAIL) { --- 3014,3019 ---- *************** *** 3033,3046 **** if (**arg == '}') break; ! // Eventually {name: value} will use "name" as a literal key and ! // {[expr]: value} for an evaluated key. ! // Temporarily: if "name" is indeed a valid key, or "[expr]" is ! // used, use the new method, like JavaScript. Otherwise fall back ! // to the old method. ! end = to_name_end(*arg, FALSE); ! if (literal || *end == ':') { if (end == *arg) { semsg(_(e_invalid_key_str), *arg); --- 3024,3035 ---- if (**arg == '}') break; ! // {name: value} uses "name" as a literal key and ! // {[expr]: value} uses an evaluated key. ! if (**arg != '[') { + char_u *end = skip_literal_key(*arg); + if (end == *arg) { semsg(_(e_invalid_key_str), *arg); *************** *** 3054,3063 **** else { isn_T *isn; - int has_bracket = **arg == '['; ! if (has_bracket) ! *arg = skipwhite(*arg + 1); if (compile_expr0(arg, cctx) == FAIL) return FAIL; isn = ((isn_T *)instr->ga_data) + instr->ga_len - 1; --- 3043,3050 ---- else { isn_T *isn; ! *arg = skipwhite(*arg + 1); if (compile_expr0(arg, cctx) == FAIL) return FAIL; isn = ((isn_T *)instr->ga_data) + instr->ga_len - 1; *************** *** 3071,3086 **** FALSE, FALSE) == FAIL) return FAIL; } ! if (has_bracket) { ! *arg = skipwhite(*arg); ! if (**arg != ']') ! { ! emsg(_(e_missing_matching_bracket_after_dict_key)); ! return FAIL; ! } ! ++*arg; } } // Check for duplicate keys, if using string keys. --- 3058,3070 ---- FALSE, FALSE) == FAIL) return FAIL; } ! *arg = skipwhite(*arg); ! if (**arg != ']') { ! emsg(_(e_missing_matching_bracket_after_dict_key)); ! return FAIL; } + ++*arg; } // Check for duplicate keys, if using string keys. *************** *** 3766,3773 **** * $VAR environment variable * (expression) nested expression * [expr, expr] List ! * {key: val, key: val} Dictionary ! * #{key: val, key: val} Dictionary with literal keys * * Also handle: * ! in front logical NOT --- 3750,3756 ---- * $VAR environment variable * (expression) nested expression * [expr, expr] List ! * {key: val, [key]: val} Dictionary * * Also handle: * ! in front logical NOT *************** *** 3884,3901 **** break; /* - * Dictionary: #{key: val, key: val} - */ - case '#': if ((*arg)[1] == '{') - { - ++*arg; - ret = compile_dict(arg, cctx, TRUE, ppconst); - } - else - ret = NOTDONE; - break; - - /* * Lambda: {arg, arg -> expr} * Dictionary: {'key': val, 'key': val} */ --- 3867,3872 ---- *************** *** 3910,3916 **** if (ret != FAIL && *start == '>') ret = compile_lambda(arg, cctx); else ! ret = compile_dict(arg, cctx, FALSE, ppconst); } break; --- 3881,3887 ---- if (ret != FAIL && *start == '>') ret = compile_lambda(arg, cctx); else ! ret = compile_dict(arg, cctx, ppconst); } break; *************** *** 4200,4206 **** } *arg = skipwhite(op + oplen); ! if (may_get_next_line(op + oplen, arg, cctx) == FAIL) return FAIL; // get the second expression --- 4171,4177 ---- } *arg = skipwhite(op + oplen); ! if (may_get_next_line_error(op + oplen, arg, cctx) == FAIL) return FAIL; // get the second expression *************** *** 7484,7496 **** switch (*ea.cmd) { case '#': ! // "#" starts a comment, but "#{" does not. ! if (ea.cmd[1] != '{') ! { ! line = (char_u *)""; ! continue; ! } ! break; case '}': { --- 7455,7463 ---- switch (*ea.cmd) { case '#': ! // "#" starts a comment ! line = (char_u *)""; ! continue; case '}': { *** ../vim-8.2.2081/src/testdir/test_vim9_assign.vim 2020-12-02 15:11:14.219994586 +0100 --- src/testdir/test_vim9_assign.vim 2020-12-02 17:06:13.499140816 +0100 *************** *** 360,385 **** var lines =<< trim END vim9script var d: dict ! extend(d, #{a: 1}) ! assert_equal(#{a: 1}, d) var d2: dict d2['one'] = 1 ! assert_equal(#{one: 1}, d2) END CheckScriptSuccess(lines) lines =<< trim END vim9script var d: dict = test_null_dict() ! extend(d, #{a: 'x'}) ! assert_equal(#{a: 'x'}, d) END CheckScriptSuccess(lines) lines =<< trim END vim9script ! extend(test_null_dict(), #{a: 'x'}) END CheckScriptFailure(lines, 'E1133:', 2) enddef --- 360,385 ---- var lines =<< trim END vim9script var d: dict ! extend(d, {a: 1}) ! assert_equal({a: 1}, d) var d2: dict d2['one'] = 1 ! assert_equal({one: 1}, d2) END CheckScriptSuccess(lines) lines =<< trim END vim9script var d: dict = test_null_dict() ! extend(d, {a: 'x'}) ! assert_equal({a: 'x'}, d) END CheckScriptSuccess(lines) lines =<< trim END vim9script ! extend(test_null_dict(), {a: 'x'}) END CheckScriptFailure(lines, 'E1133:', 2) enddef *************** *** 487,506 **** enddef def Test_assignment_dict() ! var dict1: dict = #{one: false, two: true} ! var dict2: dict = #{one: 1, two: 2} ! var dict3: dict = #{key: 'value'} ! var dict4: dict = #{one: 1, two: '2'} ! var dict5: dict = #{one: 0z01, two: 0z02} # overwrite dict3['key'] = 'another' ! assert_equal(dict3, #{key: 'another'}) dict3.key = 'yet another' ! assert_equal(dict3, #{key: 'yet another'}) var lines =<< trim END ! var dd = #{one: 1} dd.one) = 2 END CheckDefFailure(lines, 'E15:', 2) --- 487,506 ---- enddef def Test_assignment_dict() ! var dict1: dict = {one: false, two: true} ! var dict2: dict = {one: 1, two: 2} ! var dict3: dict = {key: 'value'} ! var dict4: dict = {one: 1, two: '2'} ! var dict5: dict = {one: 0z01, two: 0z02} # overwrite dict3['key'] = 'another' ! assert_equal(dict3, {key: 'another'}) dict3.key = 'yet another' ! assert_equal(dict3, {key: 'yet another'}) var lines =<< trim END ! var dd = {one: 1} dd.one) = 2 END CheckDefFailure(lines, 'E15:', 2) *************** *** 508,517 **** # empty key can be used var dd = {} dd[""] = 6 ! assert_equal({'': 6}, dd) # type becomes dict ! var somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'} # assignment to script-local dict lines =<< trim END --- 508,517 ---- # empty key can be used var dd = {} dd[""] = 6 ! assert_equal({['']: 6}, dd) # type becomes dict ! var somedict = rand() > 0 ? {a: 1, b: 2} : {a: 'a', b: 'b'} # assignment to script-local dict lines =<< trim END *************** *** 521,527 **** test['a'] = 43 return test enddef ! assert_equal(#{a: 43}, FillDict()) END CheckScriptSuccess(lines) --- 521,527 ---- test['a'] = 43 return test enddef ! assert_equal({a: 43}, FillDict()) END CheckScriptSuccess(lines) *************** *** 544,550 **** g:test['a'] = 43 return g:test enddef ! assert_equal(#{a: 43}, FillDict()) END CheckScriptSuccess(lines) --- 544,550 ---- g:test['a'] = 43 return g:test enddef ! assert_equal({a: 43}, FillDict()) END CheckScriptSuccess(lines) *************** *** 556,562 **** b:test['a'] = 43 return b:test enddef ! assert_equal(#{a: 43}, FillDict()) END CheckScriptSuccess(lines) enddef --- 556,562 ---- b:test['a'] = 43 return b:test enddef ! assert_equal({a: 43}, FillDict()) END CheckScriptSuccess(lines) enddef *************** *** 636,642 **** if has('unix') && executable('cat') # check with non-null job and channel, types must match ! thejob = job_start("cat ", #{}) thechannel = job_getchannel(thejob) job_stop(thejob, 'kill') endif --- 636,642 ---- if has('unix') && executable('cat') # check with non-null job and channel, types must match ! thejob = job_start("cat ", {}) thechannel = job_getchannel(thejob) job_stop(thejob, 'kill') endif *************** *** 827,834 **** CheckDefFailure(['var name: list = [123]'], 'expected list but got list') CheckDefFailure(['var name: list = ["xx"]'], 'expected list but got list') ! CheckDefFailure(['var name: dict = #{key: 123}'], 'expected dict but got dict') ! CheckDefFailure(['var name: dict = #{key: "xx"}'], 'expected dict but got dict') CheckDefFailure(['var name = feedkeys("0")'], 'E1031:') CheckDefFailure(['var name: number = feedkeys("0")'], 'expected number but got void') --- 827,834 ---- CheckDefFailure(['var name: list = [123]'], 'expected list but got list') CheckDefFailure(['var name: list = ["xx"]'], 'expected list but got list') ! CheckDefFailure(['var name: dict = {key: 123}'], 'expected dict but got dict') ! CheckDefFailure(['var name: dict = {key: "xx"}'], 'expected dict but got dict') CheckDefFailure(['var name = feedkeys("0")'], 'E1031:') CheckDefFailure(['var name: number = feedkeys("0")'], 'expected number but got void') *************** *** 883,899 **** for i in range(3) nrd[i] = i endfor ! assert_equal({'0': 0, '1': 1, '2': 2}, nrd) ! CheckDefFailure(["var d: dict = #{a: '', b: true}"], 'E1012: Type mismatch; expected dict but got dict', 1) ! CheckDefFailure(["var d: dict> = #{x: #{a: '', b: true}}"], 'E1012: Type mismatch; expected dict> but got dict>', 1) enddef def Test_assign_dict_unknown_type() var lines =<< trim END vim9script var mylist = [] ! mylist += [#{one: 'one'}] def Func() var dd = mylist[0] assert_equal('one', dd.one) --- 883,899 ---- for i in range(3) nrd[i] = i endfor ! assert_equal({0: 0, 1: 1, 2: 2}, nrd) ! CheckDefFailure(["var d: dict = {a: '', b: true}"], 'E1012: Type mismatch; expected dict but got dict', 1) ! CheckDefFailure(["var d: dict> = {x: {a: '', b: true}}"], 'E1012: Type mismatch; expected dict> but got dict>', 1) enddef def Test_assign_dict_unknown_type() var lines =<< trim END vim9script var mylist = [] ! mylist += [{one: 'one'}] def Func() var dd = mylist[0] assert_equal('one', dd.one) *************** *** 905,911 **** lines =<< trim END vim9script var mylist = [[]] ! mylist[0] += [#{one: 'one'}] def Func() var dd = mylist[0][0] assert_equal('one', dd.one) --- 905,911 ---- lines =<< trim END vim9script var mylist = [[]] ! mylist[0] += [{one: 'one'}] def Func() var dd = mylist[0][0] assert_equal('one', dd.one) *************** *** 1010,1016 **** g:other_var = other # type is inferred ! s:dict = {'a': 222} def GetDictVal(key: any) g:dict_val = s:dict[key] enddef --- 1010,1016 ---- g:other_var = other # type is inferred ! s:dict = {['a']: 222} def GetDictVal(key: any) g:dict_val = s:dict[key] enddef *** ../vim-8.2.2081/src/testdir/test_vim9_builtin.vim 2020-11-19 18:53:15.188492574 +0100 --- src/testdir/test_vim9_builtin.vim 2020-12-02 17:08:51.318648819 +0100 *************** *** 32,38 **** enddef def RetListAny(): list ! return items({'k': 'v'}) enddef def RetListString(): list --- 32,38 ---- enddef def RetListAny(): list ! return items({k: 'v'}) enddef def RetListString(): list *************** *** 197,206 **** assert_equal([1, 3, 2], extend([1, 2], [3], 1)) assert_equal([1, 3, 2], extend([1, 2], [3], s:number_one)) ! assert_equal(#{a: 1, b: 2, c: 3}, extend(#{a: 1, b: 2}, #{c: 3})) ! assert_equal(#{a: 1, b: 4}, extend(#{a: 1, b: 2}, #{b: 4})) ! assert_equal(#{a: 1, b: 2}, extend(#{a: 1, b: 2}, #{b: 4}, 'keep')) ! assert_equal(#{a: 1, b: 2}, extend(#{a: 1, b: 2}, #{b: 4}, s:string_keep)) var res: list> extend(res, map([1, 2], {_, v -> {}})) --- 197,206 ---- assert_equal([1, 3, 2], extend([1, 2], [3], 1)) assert_equal([1, 3, 2], extend([1, 2], [3], s:number_one)) ! assert_equal({a: 1, b: 2, c: 3}, extend({a: 1, b: 2}, {c: 3})) ! assert_equal({a: 1, b: 4}, extend({a: 1, b: 2}, {b: 4})) ! assert_equal({a: 1, b: 2}, extend({a: 1, b: 2}, {b: 4}, 'keep')) ! assert_equal({a: 1, b: 2}, extend({a: 1, b: 2}, {b: 4}, s:string_keep)) var res: list> extend(res, map([1, 2], {_, v -> {}})) *************** *** 210,218 **** CheckDefFailure(['extend([1, 2], ["x"])'], 'E1013: Argument 2: type mismatch, expected list but got list') CheckDefFailure(['extend([1, 2], [3], "x")'], 'E1013: Argument 3: type mismatch, expected number but got string') ! CheckDefFailure(['extend(#{a: 1}, 42)'], 'E1013: Argument 2: type mismatch, expected dict but got number') ! CheckDefFailure(['extend(#{a: 1}, #{b: "x"})'], 'E1013: Argument 2: type mismatch, expected dict but got dict') ! CheckDefFailure(['extend(#{a: 1}, #{b: 2}, 1)'], 'E1013: Argument 3: type mismatch, expected string but got number') enddef def Test_extend_return_type() --- 210,218 ---- CheckDefFailure(['extend([1, 2], ["x"])'], 'E1013: Argument 2: type mismatch, expected list but got list') CheckDefFailure(['extend([1, 2], [3], "x")'], 'E1013: Argument 3: type mismatch, expected number but got string') ! CheckDefFailure(['extend({a: 1}, 42)'], 'E1013: Argument 2: type mismatch, expected dict but got number') ! CheckDefFailure(['extend({a: 1}, {b: "x"})'], 'E1013: Argument 2: type mismatch, expected dict but got dict') ! CheckDefFailure(['extend({a: 1}, {b: 2}, 1)'], 'E1013: Argument 3: type mismatch, expected string but got number') enddef def Test_extend_return_type() *************** *** 254,260 **** edit Xtestfile1 hide edit Xtestfile2 hide enew ! getbufinfo(#{bufloaded: true, buflisted: true, bufmodified: false}) ->len()->assert_equal(3) bwipe Xtestfile1 Xtestfile2 enddef --- 254,260 ---- edit Xtestfile1 hide edit Xtestfile2 hide enew ! getbufinfo({bufloaded: true, buflisted: true, bufmodified: false}) ->len()->assert_equal(3) bwipe Xtestfile1 Xtestfile2 enddef *************** *** 297,312 **** var l = getloclist(1) l->assert_equal([]) ! var d = getloclist(1, #{items: 0}) ! d->assert_equal(#{items: []}) enddef def Test_getqflist_return_type() var l = getqflist() l->assert_equal([]) ! var d = getqflist(#{items: 0}) ! d->assert_equal(#{items: []}) enddef def Test_getreg() --- 297,312 ---- var l = getloclist(1) l->assert_equal([]) ! var d = getloclist(1, {items: 0}) ! d->assert_equal({items: []}) enddef def Test_getqflist_return_type() var l = getqflist() l->assert_equal([]) ! var d = getqflist({items: 0}) ! d->assert_equal({items: []}) enddef def Test_getreg() *************** *** 368,374 **** enddef def Test_keys_return_type() ! const var: list = #{a: 1, b: 2}->keys() var->assert_equal(['a', 'b']) enddef --- 368,374 ---- enddef def Test_keys_return_type() ! const var: list = {a: 1, b: 2}->keys() var->assert_equal(['a', 'b']) enddef *************** *** 388,394 **** def Test_maparg() var lnum = str2nr(expand('')) map foo bar ! maparg('foo', '', false, true)->assert_equal(#{ lnum: lnum + 1, script: 0, mode: ' ', --- 388,394 ---- def Test_maparg() var lnum = str2nr(expand('')) map foo bar ! maparg('foo', '', false, true)->assert_equal({ lnum: lnum + 1, script: 0, mode: ' ', *************** *** 428,434 **** enddef def Test_remove_return_type() ! var l = remove(#{one: [1, 2], two: [3, 4]}, 'one') var res = 0 for n in l res += n --- 428,434 ---- enddef def Test_remove_return_type() ! var l = remove({one: [1, 2], two: [3, 4]}, 'one') var res = 0 for n in l res += n *************** *** 466,473 **** new setline(1, "foo bar") :/foo ! searchcount(#{recompute: true}) ! ->assert_equal(#{ exact_match: 1, current: 1, total: 1, --- 466,473 ---- new setline(1, "foo bar") :/foo ! searchcount({recompute: true}) ! ->assert_equal({ exact_match: 1, current: 1, total: 1, *************** *** 496,503 **** enddef def Test_setloclist() ! var items = [#{filename: '/tmp/file', lnum: 1, valid: true}] ! var what = #{items: items} setqflist([], ' ', what) setloclist(0, [], ' ', what) enddef --- 496,503 ---- enddef def Test_setloclist() ! var items = [{filename: '/tmp/file', lnum: 1, valid: true}] ! var what = {items: items} setqflist([], ' ', what) setloclist(0, [], ' ', what) enddef *************** *** 570,576 **** else botright new var winnr = winnr() ! term_start(&shell, #{curwin: true}) winnr()->assert_equal(winnr) bwipe! endif --- 570,576 ---- else botright new var winnr = winnr() ! term_start(&shell, {curwin: true}) winnr()->assert_equal(winnr) bwipe! endif *************** *** 586,592 **** def Test_win_splitmove() split ! win_splitmove(1, 2, #{vertical: true, rightbelow: true}) close enddef --- 586,592 ---- def Test_win_splitmove() split ! win_splitmove(1, 2, {vertical: true, rightbelow: true}) close enddef *** ../vim-8.2.2081/src/testdir/test_vim9_cmd.vim 2020-11-25 20:09:05.517445569 +0100 --- src/testdir/test_vim9_cmd.vim 2020-12-02 17:10:22.934363077 +0100 *************** *** 251,268 **** enddef def Test_dict_member() ! var test: dict> = {'data': [3, 1, 2]} test.data->sort() ! assert_equal(#{data: [1, 2, 3]}, test) test.data ->reverse() ! assert_equal(#{data: [3, 2, 1]}, test) var lines =<< trim END vim9script ! var test: dict> = {'data': [3, 1, 2]} test.data->sort() ! assert_equal(#{data: [1, 2, 3]}, test) END CheckScriptSuccess(lines) enddef --- 251,268 ---- enddef def Test_dict_member() ! var test: dict> = {data: [3, 1, 2]} test.data->sort() ! assert_equal({data: [1, 2, 3]}, test) test.data ->reverse() ! assert_equal({data: [3, 2, 1]}, test) var lines =<< trim END vim9script ! var test: dict> = {data: [3, 1, 2]} test.data->sort() ! assert_equal({data: [1, 2, 3]}, test) END CheckScriptSuccess(lines) enddef *************** *** 308,316 **** enddef def Test_filter_is_not_modifier() ! var tags = [{'a': 1, 'b': 2}, {'x': 3, 'y': 4}] filter(tags, { _, v -> has_key(v, 'x') ? 1 : 0 }) ! assert_equal([#{x: 3, y: 4}], tags) enddef def Test_command_modifier_filter() --- 308,316 ---- enddef def Test_filter_is_not_modifier() ! var tags = [{a: 1, b: 2}, {x: 3, y: 4}] filter(tags, { _, v -> has_key(v, 'x') ? 1 : 0 }) ! assert_equal([{x: 3, y: 4}], tags) enddef def Test_command_modifier_filter() *** ../vim-8.2.2081/src/testdir/test_vim9_disassemble.vim 2020-11-23 08:31:14.101789113 +0100 --- src/testdir/test_vim9_disassemble.vim 2020-12-02 17:11:21.726179659 +0100 *************** *** 390,396 **** def s:ScriptFuncNew() var ll = [1, "two", 333] ! var dd = #{one: 1, two: "val"} enddef def Test_disassemble_new() --- 390,396 ---- def s:ScriptFuncNew() var ll = [1, "two", 333] ! var dd = {one: 1, two: "val"} enddef def Test_disassemble_new() *************** *** 402,408 **** '\d PUSHNR 333\_s*' .. '\d NEWLIST size 3\_s*' .. '\d STORE $0\_s*' .. ! 'var dd = #{one: 1, two: "val"}\_s*' .. '\d PUSHS "one"\_s*' .. '\d PUSHNR 1\_s*' .. '\d PUSHS "two"\_s*' .. --- 402,408 ---- '\d PUSHNR 333\_s*' .. '\d NEWLIST size 3\_s*' .. '\d STORE $0\_s*' .. ! 'var dd = {one: 1, two: "val"}\_s*' .. '\d PUSHS "one"\_s*' .. '\d PUSHNR 1\_s*' .. '\d PUSHS "two"\_s*' .. *************** *** 1292,1298 **** enddef def DictMember(): number ! var d = #{item: 1} var res = d.item res = d["item"] return res --- 1292,1298 ---- enddef def DictMember(): number ! var d = {item: 1} var res = d.item res = d["item"] return res *************** *** 1301,1307 **** def Test_disassemble_dict_member() var instr = execute('disassemble DictMember') assert_match('DictMember\_s*' .. ! 'var d = #{item: 1}\_s*' .. '\d PUSHS "item"\_s*' .. '\d PUSHNR 1\_s*' .. '\d NEWDICT size 1\_s*' .. --- 1301,1307 ---- def Test_disassemble_dict_member() var instr = execute('disassemble DictMember') assert_match('DictMember\_s*' .. ! 'var d = {item: 1}\_s*' .. '\d PUSHS "item"\_s*' .. '\d PUSHNR 1\_s*' .. '\d NEWDICT size 1\_s*' .. *************** *** 1473,1482 **** ['[1, 2] is aList', 'COMPARELIST is'], ['[1, 2] isnot aList', 'COMPARELIST isnot'], ! ['#{a: 1} == aDict', 'COMPAREDICT =='], ! ['#{a: 1} != aDict', 'COMPAREDICT !='], ! ['#{a: 1} is aDict', 'COMPAREDICT is'], ! ['#{a: 1} isnot aDict', 'COMPAREDICT isnot'], ['{->33} == {->44}', 'COMPAREFUNC =='], ['{->33} != {->44}', 'COMPAREFUNC !='], --- 1473,1482 ---- ['[1, 2] is aList', 'COMPARELIST is'], ['[1, 2] isnot aList', 'COMPARELIST isnot'], ! ['{a: 1} == aDict', 'COMPAREDICT =='], ! ['{a: 1} != aDict', 'COMPAREDICT !='], ! ['{a: 1} is aDict', 'COMPAREDICT is'], ! ['{a: 1} isnot aDict', 'COMPAREDICT isnot'], ['{->33} == {->44}', 'COMPAREFUNC =='], ['{->33} != {->44}', 'COMPAREFUNC !='], *************** *** 1519,1525 **** ' var aString = "yy"', ' var aBlob = 0z22', ' var aList = [3, 4]', ! ' var aDict = #{x: 2}', floatDecl, ' if ' .. case[0], ' echo 42' --- 1519,1525 ---- ' var aString = "yy"', ' var aBlob = 0z22', ' var aList = [3, 4]', ! ' var aDict = {x: 2}', floatDecl, ' if ' .. case[0], ' echo 42' *** ../vim-8.2.2081/src/testdir/test_vim9_expr.vim 2020-12-02 15:11:14.219994586 +0100 --- src/testdir/test_vim9_expr.vim 2020-12-02 16:46:52.574768114 +0100 *************** *** 27,33 **** : 'two') assert_equal('one', !!0z1234 ? 'one' : 'two') assert_equal('one', !![0] ? 'one' : 'two') ! assert_equal('one', !!#{x: 0} ? 'one' : 'two') var name = 1 assert_equal('one', name ? 'one' : 'two') --- 27,33 ---- : 'two') assert_equal('one', !!0z1234 ? 'one' : 'two') assert_equal('one', !![0] ? 'one' : 'two') ! assert_equal('one', !!{x: 0} ? 'one' : 'two') var name = 1 assert_equal('one', name ? 'one' : 'two') *************** *** 206,212 **** assert_equal(123, 123 ?? 456) assert_equal('yes', 'yes' ?? 456) assert_equal([1], [1] ?? 456) ! assert_equal(#{one: 1}, #{one: 1} ?? 456) if has('float') assert_equal(0.1, 0.1 ?? 456) endif --- 206,212 ---- assert_equal(123, 123 ?? 456) assert_equal('yes', 'yes' ?? 456) assert_equal([1], [1] ?? 456) ! assert_equal({one: 1}, {one: 1} ?? 456) if has('float') assert_equal(0.1, 0.1 ?? 456) endif *************** *** 553,564 **** assert_equal(false, [1, 2, 3] == []) assert_equal(false, [1, 2, 3] == ['1', '2', '3']) ! assert_equal(true, #{one: 1, two: 2} == #{one: 1, two: 2}) ! assert_equal(false, #{one: 1, two: 2} == #{one: 2, two: 2}) ! assert_equal(false, #{one: 1, two: 2} == #{two: 2}) ! assert_equal(false, #{one: 1, two: 2} == #{}) ! assert_equal(true, g:adict == #{bbb: 8, aaa: 2}) ! assert_equal(false, #{ccc: 9, aaa: 2} == g:adict) assert_equal(true, function('g:Test_expr4_equal') == function('g:Test_expr4_equal')) assert_equal(false, function('g:Test_expr4_equal') == function('g:Test_expr4_is')) --- 553,564 ---- assert_equal(false, [1, 2, 3] == []) assert_equal(false, [1, 2, 3] == ['1', '2', '3']) ! assert_equal(true, {one: 1, two: 2} == {one: 1, two: 2}) ! assert_equal(false, {one: 1, two: 2} == {one: 2, two: 2}) ! assert_equal(false, {one: 1, two: 2} == {two: 2}) ! assert_equal(false, {one: 1, two: 2} == {}) ! assert_equal(true, g:adict == {bbb: 8, aaa: 2}) ! assert_equal(false, {ccc: 9, aaa: 2} == g:adict) assert_equal(true, function('g:Test_expr4_equal') == function('g:Test_expr4_equal')) assert_equal(false, function('g:Test_expr4_equal') == function('g:Test_expr4_is')) *************** *** 650,661 **** assert_equal(true, [1, 2, 3] != []) assert_equal(true, [1, 2, 3] != ['1', '2', '3']) ! assert_equal(false, #{one: 1, two: 2} != #{one: 1, two: 2}) ! assert_equal(true, #{one: 1, two: 2} != #{one: 2, two: 2}) ! assert_equal(true, #{one: 1, two: 2} != #{two: 2}) ! assert_equal(true, #{one: 1, two: 2} != #{}) ! assert_equal(false, g:adict != #{bbb: 8, aaa: 2}) ! assert_equal(true, #{ccc: 9, aaa: 2} != g:adict) assert_equal(false, function('g:Test_expr4_equal') != function('g:Test_expr4_equal')) assert_equal(true, function('g:Test_expr4_equal') != function('g:Test_expr4_is')) --- 650,661 ---- assert_equal(true, [1, 2, 3] != []) assert_equal(true, [1, 2, 3] != ['1', '2', '3']) ! assert_equal(false, {one: 1, two: 2} != {one: 1, two: 2}) ! assert_equal(true, {one: 1, two: 2} != {one: 2, two: 2}) ! assert_equal(true, {one: 1, two: 2} != {two: 2}) ! assert_equal(true, {one: 1, two: 2} != {}) ! assert_equal(false, g:adict != {bbb: 8, aaa: 2}) ! assert_equal(true, {ccc: 9, aaa: 2} != g:adict) assert_equal(false, function('g:Test_expr4_equal') != function('g:Test_expr4_equal')) assert_equal(true, function('g:Test_expr4_equal') != function('g:Test_expr4_is')) *************** *** 1197,1203 **** CheckScriptFailure(lines, 'E730:', 2) lines =<< trim END vim9script ! echo 'a' .. #{a: 1} END CheckScriptFailure(lines, 'E731:', 2) lines =<< trim END --- 1197,1203 ---- CheckScriptFailure(lines, 'E730:', 2) lines =<< trim END vim9script ! echo 'a' .. {a: 1} END CheckScriptFailure(lines, 'E731:', 2) lines =<< trim END *************** *** 1287,1293 **** call CheckDefFailure(["var x = 6 + xxx"], 'E1001:', 1) call CheckDefFailure(["var x = 'a' .. [1]"], 'E1105:', 1) ! call CheckDefFailure(["var x = 'a' .. #{a: 1}"], 'E1105:', 1) call CheckDefFailure(["var x = 'a' .. test_void()"], 'E1105:', 1) call CheckDefFailure(["var x = 'a' .. 0z32"], 'E1105:', 1) call CheckDefFailure(["var x = 'a' .. function('len')"], 'E1105:', 1) --- 1287,1293 ---- call CheckDefFailure(["var x = 6 + xxx"], 'E1001:', 1) call CheckDefFailure(["var x = 'a' .. [1]"], 'E1105:', 1) ! call CheckDefFailure(["var x = 'a' .. {a: 1}"], 'E1105:', 1) call CheckDefFailure(["var x = 'a' .. test_void()"], 'E1105:', 1) call CheckDefFailure(["var x = 'a' .. 0z32"], 'E1105:', 1) call CheckDefFailure(["var x = 'a' .. function('len')"], 'E1105:', 1) *************** *** 1469,1477 **** call CheckDefFailure(["var x = [1] / [2]"], 'E1036:', 1) call CheckDefFailure(["var x = [1] % [2]"], 'E1035:', 1) ! call CheckDefFailure(["var x = #{one: 1} * #{two: 2}"], 'E1036:', 1) ! call CheckDefFailure(["var x = #{one: 1} / #{two: 2}"], 'E1036:', 1) ! call CheckDefFailure(["var x = #{one: 1} % #{two: 2}"], 'E1035:', 1) call CheckDefFailure(["var x = 0xff[1]"], 'E1107:', 1) if has('float') --- 1469,1477 ---- call CheckDefFailure(["var x = [1] / [2]"], 'E1036:', 1) call CheckDefFailure(["var x = [1] % [2]"], 'E1035:', 1) ! call CheckDefFailure(["var x = {one: 1} * {two: 2}"], 'E1036:', 1) ! call CheckDefFailure(["var x = {one: 1} / {two: 2}"], 'E1036:', 1) ! call CheckDefFailure(["var x = {one: 1} % {two: 2}"], 'E1035:', 1) call CheckDefFailure(["var x = 0xff[1]"], 'E1107:', 1) if has('float') *************** *** 1796,1804 **** # line continuation inside lambda with "cond ? expr : expr" works var ll = range(3) map(ll, {k, v -> v % 2 ? { ! '111': 111 } : {} }) ! assert_equal([{}, {'111': 111}, {}], ll) ll = range(3) map(ll, {k, v -> v == 8 || v --- 1796,1804 ---- # line continuation inside lambda with "cond ? expr : expr" works var ll = range(3) map(ll, {k, v -> v % 2 ? { ! ['111']: 111 } : {} }) ! assert_equal([{}, {111: 111}, {}], ll) ll = range(3) map(ll, {k, v -> v == 8 || v *************** *** 1814,1824 **** }) assert_equal([111, 222, 111], ll) ! var dl = [{'key': 0}, {'key': 22}]->filter({ _, v -> v['key'] }) ! assert_equal([{'key': 22}], dl) ! dl = [{'key': 12}, {'foo': 34}] ! assert_equal([{'key': 12}], filter(dl, {_, v -> has_key(v, 'key') ? v['key'] == 12 : 0})) assert_equal(false, LambdaWithComments()(0)) --- 1814,1824 ---- }) assert_equal([111, 222, 111], ll) ! var dl = [{key: 0}, {key: 22}]->filter({ _, v -> v['key'] }) ! assert_equal([{key: 22}], dl) ! dl = [{key: 12}, {['foo']: 34}] ! assert_equal([{key: 12}], filter(dl, {_, v -> has_key(v, 'key') ? v['key'] == 12 : 0})) assert_equal(false, LambdaWithComments()(0)) *************** *** 1846,1854 **** 'E1106: 2 arguments too many') CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:', 1) ! CheckDefSuccess(['var Fx = {a -> #{k1: 0,', ' k2: 1}}']) ! CheckDefFailure(['var Fx = {a -> #{k1: 0', ' k2: 1}}'], 'E722:', 2) ! CheckDefFailure(['var Fx = {a -> #{k1: 0,', ' k2 1}}'], 'E720:', 2) CheckDefSuccess(['var Fx = {a -> [0,', ' 1]}']) CheckDefFailure(['var Fx = {a -> [0', ' 1]}'], 'E696:', 2) --- 1846,1854 ---- 'E1106: 2 arguments too many') CheckDefFailure(["echo 'asdf'->{a -> a}(x)"], 'E1001:', 1) ! CheckDefSuccess(['var Fx = {a -> {k1: 0,', ' k2: 1}}']) ! CheckDefFailure(['var Fx = {a -> {k1: 0', ' k2: 1}}'], 'E722:', 2) ! CheckDefFailure(['var Fx = {a -> {k1: 0,', ' k2 1}}'], 'E720:', 2) CheckDefSuccess(['var Fx = {a -> [0,', ' 1]}']) CheckDefFailure(['var Fx = {a -> [0', ' 1]}'], 'E696:', 2) *************** *** 1894,1952 **** var lines =<< trim END assert_equal(g:dict_empty, {}) assert_equal(g:dict_empty, { }) ! assert_equal(g:dict_one, {'one': 1}) var key = 'one' var val = 1 assert_equal(g:dict_one, {[key]: val}) var numbers: dict = {a: 1, b: 2, c: 3} ! numbers = #{a: 1} ! numbers = #{} var strings: dict = {a: 'a', b: 'b', c: 'c'} ! strings = #{a: 'x'} ! strings = #{} var mixed: dict = {a: 'a', b: 42} ! mixed = #{a: 'x'} ! mixed = #{a: 234} ! mixed = #{} ! ! var dictlist: dict> = #{absent: [], present: ['hi']} ! dictlist = #{absent: ['hi'], present: []} ! dictlist = #{absent: [], present: []} ! ! var dictdict: dict> = #{one: #{a: 'text'}, two: #{}} ! dictdict = #{one: #{}, two: #{a: 'text'}} ! dictdict = #{one: #{}, two: #{}} ! assert_equal({'': 0}, {matchstr('string', 'wont match'): 0}) assert_equal(g:test_space_dict, {['']: 'empty', [' ']: 'space'}) assert_equal(g:test_hash_dict, {one: 1, two: 2}) END CheckDefAndScriptSuccess(lines) ! CheckDefFailure(["var x = #{a:8}"], 'E1069:', 1) ! CheckDefFailure(["var x = #{a : 8}"], 'E1068:', 1) ! CheckDefFailure(["var x = #{a :8}"], 'E1068:', 1) ! CheckDefFailure(["var x = #{a: 8 , b: 9}"], 'E1068:', 1) ! CheckDefFailure(["var x = #{a: 1,b: 2}"], 'E1069:', 1) ! ! CheckDefFailure(["var x = #{8: 8}"], 'E1014:', 1) ! CheckDefFailure(["var x = #{xxx}"], 'E720:', 1) ! CheckDefFailure(["var x = #{xxx: 1", "var y = 2"], 'E722:', 2) ! CheckDefFailure(["var x = #{xxx: 1,"], 'E723:', 2) ! CheckDefFailure(["var x = {'a': xxx}"], 'E1001:', 1) ! CheckDefFailure(["var x = {xx-x: 8}"], 'E1001:', 1) ! CheckDefFailure(["var x = #{a: 1, a: 2}"], 'E721:', 1) CheckDefExecFailure(["var x = g:anint.member"], 'E715:', 1) CheckDefExecFailure(["var x = g:dict_empty.member"], 'E716:', 1) ! CheckDefExecFailure(['var x: dict = #{a: 234, b: "1"}'], 'E1012:', 1) ! CheckDefExecFailure(['var x: dict = #{a: "x", b: 134}'], 'E1012:', 1) ! CheckDefExecFailure(['var x: dict = #{a: 234, b: "1"}'], 'E1012:', 1) ! CheckDefExecFailure(['var x: dict = #{a: "x", b: 134}'], 'E1012:', 1) CheckDefFailure(['var x = ({'], 'E723:', 2) CheckDefExecFailure(['{}[getftype("")]'], 'E716: Key not present in Dictionary: ""', 1) --- 1894,1961 ---- var lines =<< trim END assert_equal(g:dict_empty, {}) assert_equal(g:dict_empty, { }) ! assert_equal(g:dict_one, {['one']: 1}) var key = 'one' var val = 1 assert_equal(g:dict_one, {[key]: val}) var numbers: dict = {a: 1, b: 2, c: 3} ! numbers = {a: 1} ! numbers = {} var strings: dict = {a: 'a', b: 'b', c: 'c'} ! strings = {a: 'x'} ! strings = {} ! ! var dash = {xx-x: 8} ! assert_equal({['xx-x']: 8}, dash) ! ! var dnr = {8: 8} ! assert_equal({['8']: 8}, dnr) var mixed: dict = {a: 'a', b: 42} ! mixed = {a: 'x'} ! mixed = {a: 234} ! mixed = {} ! ! var dictlist: dict> = {absent: [], present: ['hi']} ! dictlist = {absent: ['hi'], present: []} ! dictlist = {absent: [], present: []} ! ! var dictdict: dict> = {one: {a: 'text'}, two: {}} ! dictdict = {one: {}, two: {a: 'text'}} ! dictdict = {one: {}, two: {}} ! assert_equal({['']: 0}, {[matchstr('string', 'wont match')]: 0}) assert_equal(g:test_space_dict, {['']: 'empty', [' ']: 'space'}) assert_equal(g:test_hash_dict, {one: 1, two: 2}) END CheckDefAndScriptSuccess(lines) ! # legacy syntax doesn't work ! CheckDefFailure(["var x = #{key: 8}"], 'E1097:', 2) ! CheckDefFailure(["var x = {'key': 8}"], 'E1014:', 1) ! CheckDefFailure(["var x = 'a' .. #{a: 1}"], 'E1097:', 2) ! ! CheckDefFailure(["var x = {a:8}"], 'E1069:', 1) ! CheckDefFailure(["var x = {a : 8}"], 'E1059:', 1) ! CheckDefFailure(["var x = {a :8}"], 'E1059:', 1) ! CheckDefFailure(["var x = {a: 8 , b: 9}"], 'E1068:', 1) ! CheckDefFailure(["var x = {a: 1,b: 2}"], 'E1069:', 1) ! ! CheckDefFailure(["var x = {xxx}"], 'E720:', 1) ! CheckDefFailure(["var x = {xxx: 1", "var y = 2"], 'E722:', 2) ! CheckDefFailure(["var x = {xxx: 1,"], 'E723:', 2) ! CheckDefFailure(["var x = {['a']: xxx}"], 'E1001:', 1) ! CheckDefFailure(["var x = {a: 1, a: 2}"], 'E721:', 1) CheckDefExecFailure(["var x = g:anint.member"], 'E715:', 1) CheckDefExecFailure(["var x = g:dict_empty.member"], 'E716:', 1) ! CheckDefExecFailure(['var x: dict = {a: 234, b: "1"}'], 'E1012:', 1) ! CheckDefExecFailure(['var x: dict = {a: "x", b: 134}'], 'E1012:', 1) ! CheckDefExecFailure(['var x: dict = {a: 234, b: "1"}'], 'E1012:', 1) ! CheckDefExecFailure(['var x: dict = {a: "x", b: 134}'], 'E1012:', 1) CheckDefFailure(['var x = ({'], 'E723:', 2) CheckDefExecFailure(['{}[getftype("")]'], 'E716: Key not present in Dictionary: ""', 1) *************** *** 1956,2044 **** var lines =<< trim END vim9script var d = { ! 'one': 1, ! 'two': 2, } ! assert_equal({'one': 1, 'two': 2}, d) d = { # comment ! 'one': # comment 1, # comment # comment ! 'two': 2, } ! assert_equal({'one': 1, 'two': 2}, d) END CheckScriptSuccess(lines) lines =<< trim END vim9script ! var d = { "one": "one", "two": "two", } ! assert_equal({'one': 'one', 'two': 'two'}, d) END CheckScriptSuccess(lines) lines =<< trim END vim9script ! var d = #{one: 1, two: 2, } ! assert_equal({'one': 1, 'two': 2}, d) END CheckScriptSuccess(lines) lines =<< trim END vim9script ! var d = #{one:1, two: 2} END CheckScriptFailure(lines, 'E1069:', 2) lines =<< trim END vim9script ! var d = #{one: 1,two: 2} END CheckScriptFailure(lines, 'E1069:', 2) lines =<< trim END vim9script ! var d = #{one : 1} END ! CheckScriptFailure(lines, 'E1068:', 2) lines =<< trim END vim9script ! var d = #{one:1} END CheckScriptFailure(lines, 'E1069:', 2) lines =<< trim END vim9script ! var d = #{one: 1 , two: 2} END CheckScriptFailure(lines, 'E1068:', 2) lines =<< trim END vim9script ! var l: dict = #{a: 234, b: 'x'} END CheckScriptFailure(lines, 'E1012:', 2) lines =<< trim END vim9script ! var l: dict = #{a: 'x', b: 234} END CheckScriptFailure(lines, 'E1012:', 2) lines =<< trim END vim9script ! var l: dict = #{a: 'x', b: 234} END CheckScriptFailure(lines, 'E1012:', 2) lines =<< trim END vim9script ! var l: dict = #{a: 234, b: 'x'} END CheckScriptFailure(lines, 'E1012:', 2) --- 1965,2053 ---- var lines =<< trim END vim9script var d = { ! ['one']: 1, ! ['two']: 2, } ! assert_equal({one: 1, two: 2}, d) d = { # comment ! ['one']: # comment 1, # comment # comment ! ['two']: 2, } ! assert_equal({one: 1, two: 2}, d) END CheckScriptSuccess(lines) lines =<< trim END vim9script ! var d = { ["one"]: "one", ["two"]: "two", } ! assert_equal({one: 'one', two: 'two'}, d) END CheckScriptSuccess(lines) lines =<< trim END vim9script ! var d = {one: 1, two: 2, } ! assert_equal({one: 1, two: 2}, d) END CheckScriptSuccess(lines) lines =<< trim END vim9script ! var d = {one:1, two: 2} END CheckScriptFailure(lines, 'E1069:', 2) lines =<< trim END vim9script ! var d = {one: 1,two: 2} END CheckScriptFailure(lines, 'E1069:', 2) lines =<< trim END vim9script ! var d = {one : 1} END ! CheckScriptFailure(lines, 'E1059:', 2) lines =<< trim END vim9script ! var d = {one:1} END CheckScriptFailure(lines, 'E1069:', 2) lines =<< trim END vim9script ! var d = {one: 1 , two: 2} END CheckScriptFailure(lines, 'E1068:', 2) lines =<< trim END vim9script ! var l: dict = {a: 234, b: 'x'} END CheckScriptFailure(lines, 'E1012:', 2) lines =<< trim END vim9script ! var l: dict = {a: 'x', b: 234} END CheckScriptFailure(lines, 'E1012:', 2) lines =<< trim END vim9script ! var l: dict = {a: 'x', b: 234} END CheckScriptFailure(lines, 'E1012:', 2) lines =<< trim END vim9script ! var l: dict = {a: 234, b: 'x'} END CheckScriptFailure(lines, 'E1012:', 2) *************** *** 2047,2053 **** def Failing() job_stop() enddef ! var dict = #{name: Failing} END if has('channel') CheckScriptFailure(lines, 'E119:', 1) --- 2056,2062 ---- def Failing() job_stop() enddef ! var dict = {name: Failing} END if has('channel') CheckScriptFailure(lines, 'E119:', 1) *************** *** 2067,2081 **** ]) assert_equal(1, d .one) ! d = {'1': 1, '_': 2} assert_equal(1, d .1) assert_equal(2, d ._) # getting the one member should clear the dict after getting the item ! assert_equal('one', #{one: 'one'}.one) ! assert_equal('one', #{one: 'one'}[g:oneString]) CheckDefFailure(["var x = g:dict_one.#$!"], 'E1002:', 1) CheckDefExecFailure(["var d: dict", "echo d['a']"], 'E716:', 2) --- 2076,2090 ---- ]) assert_equal(1, d .one) ! d = {1: 1, _: 2} assert_equal(1, d .1) assert_equal(2, d ._) # getting the one member should clear the dict after getting the item ! assert_equal('one', {one: 'one'}.one) ! assert_equal('one', {one: 'one'}[g:oneString]) CheckDefFailure(["var x = g:dict_one.#$!"], 'E1002:', 1) CheckDefExecFailure(["var d: dict", "echo d['a']"], 'E716:', 2) *************** *** 2141,2147 **** assert_equal([], g:testlist[1:-4]) assert_equal([], g:testlist[1:-9]) ! g:testdict = #{a: 1, b: 2} assert_equal(1, g:testdict['a']) assert_equal(2, g:testdict['b']) END --- 2150,2156 ---- assert_equal([], g:testlist[1:-4]) assert_equal([], g:testlist[1:-9]) ! g:testdict = {a: 1, b: 2} assert_equal(1, g:testdict['a']) assert_equal(2, g:testdict['b']) END *************** *** 2172,2178 **** def Test_expr_member_vim9script() var lines =<< trim END vim9script ! var d = #{one: 'one', two: 'two', 1: 1, --- 2181,2187 ---- def Test_expr_member_vim9script() var lines =<< trim END vim9script ! var d = {one: 'one', two: 'two', 1: 1, *************** *** 2406,2412 **** assert_equal(true, !test_null_dict()) assert_equal(true, !{}) ! assert_equal(false, !{'yes': 'no'}) if has('channel') assert_equal(true, !test_null_job()) --- 2415,2421 ---- assert_equal(true, !test_null_dict()) assert_equal(true, !{}) ! assert_equal(false, !{yes: 'no'}) if has('channel') assert_equal(true, !test_null_job()) *************** *** 2433,2439 **** call CheckDefFailure(["var x = +'xx'"], "E1030:", 1) call CheckDefFailure(["var x = -0z12"], "E974:", 1) call CheckDefExecFailure(["var x = -[8]"], "E39:", 1) ! call CheckDefExecFailure(["var x = -{'a': 1}"], "E39:", 1) call CheckDefFailure(["var x = @"], "E1002:", 1) call CheckDefFailure(["var x = @<"], "E354:", 1) --- 2442,2448 ---- call CheckDefFailure(["var x = +'xx'"], "E1030:", 1) call CheckDefFailure(["var x = -0z12"], "E974:", 1) call CheckDefExecFailure(["var x = -[8]"], "E39:", 1) ! call CheckDefExecFailure(["var x = -{a: 1}"], "E39:", 1) call CheckDefFailure(["var x = @"], "E1002:", 1) call CheckDefFailure(["var x = @<"], "E354:", 1) *************** *** 2464,2471 **** call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 1) call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) ! call CheckDefExecFailure(["#{a: 1->len()"], 'E722:', 1) ! call CheckDefExecFailure(["{'a': 1->len()"], 'E723:', 2) endfunc let g:Funcrefs = [function('add')] --- 2473,2480 ---- call CheckDefFailure(["'yes'->", "Echo()"], 'E488: Trailing characters: ->', 1) call CheckDefExecFailure(["[1, 2->len()"], 'E697:', 2) ! call CheckDefExecFailure(["{a: 1->len()"], 'E451:', 1) ! call CheckDefExecFailure(["{['a']: 1->len()"], 'E723:', 2) endfunc let g:Funcrefs = [function('add')] *************** *** 2507,2513 **** assert_equal([2, 5, 8], l) # dict member ! var d = #{key: 123} assert_equal(123, d.key) enddef --- 2516,2522 ---- assert_equal([2, 5, 8], l) # dict member ! var d = {key: 123} assert_equal(123, d.key) enddef *************** *** 2594,2600 **** def Test_expr7_dict_subscript() var lines =<< trim END vim9script ! var l = [#{lnum: 2}, #{lnum: 1}] var res = l[0].lnum > l[1].lnum assert_true(res) END --- 2603,2609 ---- def Test_expr7_dict_subscript() var lines =<< trim END vim9script ! var l = [{lnum: 2}, {lnum: 1}] var res = l[0].lnum > l[1].lnum assert_true(res) END *************** *** 2629,2635 **** assert_equal('1', l[ 1]) ! var d = #{one: 33} assert_equal(33, d. one) enddef --- 2638,2644 ---- assert_equal('1', l[ 1]) ! var d = {one: 33} assert_equal(33, d. one) enddef *************** *** 2643,2651 **** bwipe! var bufnr = bufnr() ! var loclist = [#{bufnr: bufnr, lnum: 42, col: 17, text: 'wrong'}] loclist->setloclist(0) ! assert_equal([#{bufnr: bufnr, lnum: 42, col: 17, text: 'wrong', --- 2652,2660 ---- bwipe! var bufnr = bufnr() ! var loclist = [{bufnr: bufnr, lnum: 42, col: 17, text: 'wrong'}] loclist->setloclist(0) ! assert_equal([{bufnr: bufnr, lnum: 42, col: 17, text: 'wrong', *************** *** 2657,2663 **** module: ''} ], getloclist(0)) ! var result: bool = get(#{n: 0}, 'n', 0) assert_equal(false, result) enddef --- 2666,2672 ---- module: ''} ], getloclist(0)) ! var result: bool = get({n: 0}, 'n', 0) assert_equal(false, result) enddef *** ../vim-8.2.2081/src/testdir/test_vim9_func.vim 2020-11-25 19:15:15.443211576 +0100 --- src/testdir/test_vim9_func.vim 2020-12-02 17:15:42.057367208 +0100 *************** *** 30,36 **** END call writefile(lines, 'XTest_compile_error') var buf = RunVimInTerminal('-S XTest_compile_error', ! #{rows: 10, wait_for_ruler: 0}) var text = '' for loop in range(100) text = '' --- 30,36 ---- END call writefile(lines, 'XTest_compile_error') var buf = RunVimInTerminal('-S XTest_compile_error', ! {rows: 10, wait_for_ruler: 0}) var text = '' for loop in range(100) text = '' *************** *** 838,853 **** def DictFunc(arg: dict) dictvar = arg enddef ! {'a': 1, 'b': 2}->DictFunc() ! dictvar->assert_equal(#{a: 1, b: 2}) def CompiledDict() ! {'a': 3, 'b': 4}->DictFunc() enddef CompiledDict() ! dictvar->assert_equal(#{a: 3, b: 4}) ! #{a: 3, b: 4}->DictFunc() ! dictvar->assert_equal(#{a: 3, b: 4}) ('text')->MyFunc() name->assert_equal('text') --- 838,853 ---- def DictFunc(arg: dict) dictvar = arg enddef ! {a: 1, b: 2}->DictFunc() ! dictvar->assert_equal({a: 1, b: 2}) def CompiledDict() ! {a: 3, b: 4}->DictFunc() enddef CompiledDict() ! dictvar->assert_equal({a: 3, b: 4}) ! {a: 3, b: 4}->DictFunc() ! dictvar->assert_equal({a: 3, b: 4}) ('text')->MyFunc() name->assert_equal('text') *************** *** 1272,1278 **** lines =<< trim END vim9script def Func() ! var db = #{foo: 1, bar: 2} # comment var x = db.asdf enddef --- 1272,1278 ---- lines =<< trim END vim9script def Func() ! var db = {foo: 1, bar: 2} # comment var x = db.asdf enddef *************** *** 1607,1613 **** return popup_filter_menu(winid, key) enddef ! popup_create('popup', #{filter: Filter}) feedkeys("o\r", 'xnt') END CheckScriptSuccess(lines) --- 1607,1613 ---- return popup_filter_menu(winid, key) enddef ! popup_create('popup', {filter: Filter}) feedkeys("o\r", 'xnt') END CheckScriptSuccess(lines) *************** *** 1639,1645 **** writefile(['222'], 'XclosureDir/file2') writefile(['333'], 'XclosureDir/tdir/file3') ! TreeWalk('XclosureDir')->assert_equal(['file1', 'file2', {'tdir': ['file3']}]) delete('XclosureDir', 'rf') enddef --- 1639,1645 ---- writefile(['222'], 'XclosureDir/file2') writefile(['333'], 'XclosureDir/tdir/file3') ! TreeWalk('XclosureDir')->assert_equal(['file1', 'file2', {tdir: ['file3']}]) delete('XclosureDir', 'rf') enddef *************** *** 1672,1691 **** def Test_partial_call() var Xsetlist = function('setloclist', [0]) ! Xsetlist([], ' ', {'title': 'test'}) ! getloclist(0, {'title': 1})->assert_equal({'title': 'test'}) Xsetlist = function('setloclist', [0, [], ' ']) ! Xsetlist({'title': 'test'}) ! getloclist(0, {'title': 1})->assert_equal({'title': 'test'}) Xsetlist = function('setqflist') ! Xsetlist([], ' ', {'title': 'test'}) ! getqflist({'title': 1})->assert_equal({'title': 'test'}) Xsetlist = function('setqflist', [[], ' ']) ! Xsetlist({'title': 'test'}) ! getqflist({'title': 1})->assert_equal({'title': 'test'}) var Len: func: number = function('len', ['word']) assert_equal(4, Len()) --- 1672,1691 ---- def Test_partial_call() var Xsetlist = function('setloclist', [0]) ! Xsetlist([], ' ', {title: 'test'}) ! getloclist(0, {title: 1})->assert_equal({title: 'test'}) Xsetlist = function('setloclist', [0, [], ' ']) ! Xsetlist({title: 'test'}) ! getloclist(0, {title: 1})->assert_equal({title: 'test'}) Xsetlist = function('setqflist') ! Xsetlist([], ' ', {title: 'test'}) ! getqflist({title: 1})->assert_equal({title: 'test'}) Xsetlist = function('setqflist', [[], ' ']) ! Xsetlist({title: 'test'}) ! getqflist({title: 1})->assert_equal({title: 'test'}) var Len: func: number = function('len', ['word']) assert_equal(4, Len()) *** ../vim-8.2.2081/src/testdir/test_vim9_script.vim 2020-12-02 14:24:26.973652266 +0100 --- src/testdir/test_vim9_script.vim 2020-12-02 17:17:24.953045956 +0100 *************** *** 177,190 **** cl[1] = 88 constlist->assert_equal([1, [77, 88], 3]) ! var vardict = #{five: 5, six: 6} ! const constdict = #{one: 1, two: vardict, three: 3} vardict['five'] = 55 # TODO: does not work yet # constdict['two']['six'] = 66 var cd = constdict['two'] cd['six'] = 66 ! constdict->assert_equal(#{one: 1, two: #{five: 55, six: 66}, three: 3}) END CheckDefAndScriptSuccess(lines) enddef --- 177,190 ---- cl[1] = 88 constlist->assert_equal([1, [77, 88], 3]) ! var vardict = {five: 5, six: 6} ! const constdict = {one: 1, two: vardict, three: 3} vardict['five'] = 55 # TODO: does not work yet # constdict['two']['six'] = 66 var cd = constdict['two'] cd['six'] = 66 ! constdict->assert_equal({one: 1, two: {five: 55, six: 66}, three: 3}) END CheckDefAndScriptSuccess(lines) enddef *************** *** 212,225 **** CheckScriptFailure(['vim9script'] + lines, 'E684:', 3) lines =<< trim END ! const dd = #{one: 1, two: 2} dd["one"] = 99 END CheckDefExecFailure(lines, 'E1121:', 2) CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) lines =<< trim END ! const dd = #{one: 1, two: 2} dd["three"] = 99 END CheckDefExecFailure(lines, 'E1120:') --- 212,225 ---- CheckScriptFailure(['vim9script'] + lines, 'E684:', 3) lines =<< trim END ! const dd = {one: 1, two: 2} dd["one"] = 99 END CheckDefExecFailure(lines, 'E1121:', 2) CheckScriptFailure(['vim9script'] + lines, 'E741:', 3) lines =<< trim END ! const dd = {one: 1, two: 2} dd["three"] = 99 END CheckDefExecFailure(lines, 'E1120:') *************** *** 385,391 **** endtry assert_equal(121, n) ! var d = #{one: 1} try n = d[g:astring] catch /E716:/ --- 385,391 ---- endtry assert_equal(121, n) ! var d = {one: 1} try n = d[g:astring] catch /E716:/ *************** *** 775,781 **** g:imported_func = Exported() def GetExported(): string ! var local_dict = #{ref: Exported} return local_dict.ref() enddef g:funcref_result = GetExported() --- 775,781 ---- g:imported_func = Exported() def GetExported(): string ! var local_dict = {ref: Exported} return local_dict.ref() enddef g:funcref_result = GetExported() *************** *** 1133,1139 **** END writefile(export, 'XexportCmd.vim') ! var buf = RunVimInTerminal('-c "import Foo from ''./XexportCmd.vim''"', #{ rows: 6, wait_for_ruler: 0}) WaitForAssert({-> assert_match('^E1094:', term_getline(buf, 5))}) --- 1133,1139 ---- END writefile(export, 'XexportCmd.vim') ! var buf = RunVimInTerminal('-c "import Foo from ''./XexportCmd.vim''"', { rows: 6, wait_for_ruler: 0}) WaitForAssert({-> assert_match('^E1094:', term_getline(buf, 5))}) *************** *** 1733,1739 **** execute 'echomsg' (n ? '"true"' : '"no"') assert_match('^true$', Screenline(&lines)) ! echomsg [1, 2, 3] #{a: 1, b: 2} assert_match('^\[1, 2, 3\] {''a'': 1, ''b'': 2}$', Screenline(&lines)) CheckDefFailure(['execute xxx'], 'E1001:', 1) --- 1733,1739 ---- execute 'echomsg' (n ? '"true"' : '"no"') assert_match('^true$', Screenline(&lines)) ! echomsg [1, 2, 3] {a: 1, b: 2} assert_match('^\[1, 2, 3\] {''a'': 1, ''b'': 2}$', Screenline(&lines)) CheckDefFailure(['execute xxx'], 'E1001:', 1) *************** *** 2024,2049 **** assert_equal(['one', 'two', 'three'], mylist) var mydict = { ! 'one': 1, ! 'two': 2, ! 'three': 3, } # comment ! assert_equal({'one': 1, 'two': 2, 'three': 3}, mydict) ! mydict = #{ one: 1, # comment two: # comment 2, # comment three: 3 # comment } ! assert_equal(#{one: 1, two: 2, three: 3}, mydict) ! mydict = #{ one: 1, two: 2, three: 3 } ! assert_equal(#{one: 1, two: 2, three: 3}, mydict) assert_equal( ['one', 'two', 'three'], --- 2024,2049 ---- assert_equal(['one', 'two', 'three'], mylist) var mydict = { ! ['one']: 1, ! ['two']: 2, ! ['three']: 3, } # comment ! assert_equal({one: 1, two: 2, three: 3}, mydict) ! mydict = { one: 1, # comment two: # comment 2, # comment three: 3 # comment } ! assert_equal({one: 1, two: 2, three: 3}, mydict) ! mydict = { one: 1, two: 2, three: 3 } ! assert_equal({one: 1, two: 2, three: 3}, mydict) assert_equal( ['one', 'two', 'three'], *************** *** 2864,2870 **** END writefile([''], 'Xdidcmd') writefile(lines, 'XcallFunc') ! var buf = RunVimInTerminal('-S XcallFunc', #{rows: 6}) # define Afunc() on the command line term_sendkeys(buf, ":def Afunc()\Bfunc()\enddef\") term_sendkeys(buf, ":call CheckAndQuit()\") --- 2864,2870 ---- END writefile([''], 'Xdidcmd') writefile(lines, 'XcallFunc') ! var buf = RunVimInTerminal('-S XcallFunc', {rows: 6}) # define Afunc() on the command line term_sendkeys(buf, ":def Afunc()\Bfunc()\enddef\") term_sendkeys(buf, ":call CheckAndQuit()\") *************** *** 2959,2965 **** g:caught = 'yes' endtry enddef ! popup_menu('popup', #{callback: Callback}) feedkeys("\r", 'xt') END CheckScriptSuccess(lines) --- 2959,2965 ---- g:caught = 'yes' endtry enddef ! popup_menu('popup', {callback: Callback}) feedkeys("\r", 'xt') END CheckScriptSuccess(lines) *************** *** 2981,2987 **** sleep 1m source += l enddef ! var myjob = job_start('echo burp', #{out_cb: Out_cb, exit_cb: Exit_cb, mode: 'raw'}) sleep 100m END writefile(lines, 'Xdef') --- 2981,2987 ---- sleep 1m source += l enddef ! var myjob = job_start('echo burp', {out_cb: Out_cb, exit_cb: Exit_cb, mode: 'raw'}) sleep 100m END writefile(lines, 'Xdef') *** ../vim-8.2.2081/src/testdir/test_popupwin.vim 2020-11-28 21:56:02.451507313 +0100 --- src/testdir/test_popupwin.vim 2020-12-02 17:24:04.095799560 +0100 *************** *** 2172,2178 **** endfunc def CreatePopup(text: list) ! popup_create(text, #{ \ minwidth: 30, \ maxwidth: 30, \ minheight: 4, --- 2172,2178 ---- endfunc def CreatePopup(text: list) ! popup_create(text, { \ minwidth: 30, \ maxwidth: 30, \ minheight: 4, *************** *** 2717,2723 **** split wincmd b assert_equal(2, winnr()) ! var buf = term_start(&shell, #{hidden: 1}) popup_create(buf, {}) TermWait(buf, 100) popup_clear(true) --- 2717,2723 ---- split wincmd b assert_equal(2, winnr()) ! var buf = term_start(&shell, {hidden: 1}) popup_create(buf, {}) TermWait(buf, 100) popup_clear(true) *** ../vim-8.2.2081/src/testdir/test_textprop.vim 2020-09-27 22:47:01.884163380 +0200 --- src/testdir/test_textprop.vim 2020-12-02 17:31:19.030441033 +0100 *************** *** 219,233 **** # Multiple props per line, start on the first, should find the second. new ['the quikc bronw fox jumsp over the layz dog']->repeat(2)->setline(1) ! prop_type_add('misspell', #{highlight: 'ErrorMsg'}) for lnum in [1, 2] for col in [8, 14, 24, 38] ! prop_add(lnum, col, #{type: 'misspell', length: 2}) endfor endfor cursor(1, 8) ! var expected = {'lnum': 1, 'id': 0, 'col': 14, 'end': 1, 'type': 'misspell', 'length': 2, 'start': 1} ! var result = prop_find(#{type: 'misspell', skipstart: true}, 'f') assert_equal(expected, result) prop_type_delete('misspell') --- 219,233 ---- # Multiple props per line, start on the first, should find the second. new ['the quikc bronw fox jumsp over the layz dog']->repeat(2)->setline(1) ! prop_type_add('misspell', {highlight: 'ErrorMsg'}) for lnum in [1, 2] for col in [8, 14, 24, 38] ! prop_add(lnum, col, {type: 'misspell', length: 2}) endfor endfor cursor(1, 8) ! var expected = {lnum: 1, id: 0, col: 14, end: 1, type: 'misspell', length: 2, start: 1} ! var result = prop_find({type: 'misspell', skipstart: true}, 'f') assert_equal(expected, result) prop_type_delete('misspell') *************** *** 322,328 **** endfunc def Test_prop_add_vim9() ! prop_type_add('comment', #{ highlight: 'Directory', priority: 123, start_incl: true, --- 322,328 ---- endfunc def Test_prop_add_vim9() ! prop_type_add('comment', { highlight: 'Directory', priority: 123, start_incl: true, *************** *** 336,342 **** new AddPropTypes() SetupPropsInFirstLine() ! assert_equal(1, prop_remove({'type': 'three', 'id': 13, 'both': true, 'all': true})) DeletePropTypes() bwipe! enddef --- 336,342 ---- new AddPropTypes() SetupPropsInFirstLine() ! assert_equal(1, prop_remove({type: 'three', id: 13, both: true, all: true})) DeletePropTypes() bwipe! enddef *** ../vim-8.2.2081/src/version.c 2020-12-02 15:11:14.219994586 +0100 --- src/version.c 2020-12-02 15:38:47.067169734 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2082, /**/ -- Q: What's orange and sounds like a parrot? A: A carrot /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///