To: vim_dev@googlegroups.com Subject: Patch 8.2.0467 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0467 Problem: Vim9: some errors are not tested Solution: Add more tests. Fix that Vim9 script flag is not reset. Files: src/vim9compile.c, src/scriptfile.c, src/dict.c, src/testdir/test_vim9_expr.vim, src/testdir/test_vim9_script.vim *** ../vim-8.2.0466/src/vim9compile.c 2020-03-28 14:53:17.104420156 +0100 --- src/vim9compile.c 2020-03-28 19:26:07.571127315 +0100 *************** *** 1815,1821 **** if (*(*arg + 1) == ':') { // load namespaced variable ! name = vim_strnsave(*arg + 2, end - (*arg + 2)); if (name == NULL) return FAIL; --- 1815,1824 ---- if (*(*arg + 1) == ':') { // load namespaced variable ! if (end <= *arg + 2) ! name = vim_strsave((char_u *)"[empty]"); ! else ! name = vim_strnsave(*arg + 2, end - (*arg + 2)); if (name == NULL) return FAIL; *************** *** 1833,1841 **** { res = compile_load_scriptvar(cctx, name, NULL, NULL, error); } else { ! semsg("Namespace not supported yet: %s", *arg); goto theend; } } --- 1836,1859 ---- { res = compile_load_scriptvar(cctx, name, NULL, NULL, error); } + else if (**arg == 'b') + { + semsg("Namespace b: not supported yet: %s", *arg); + goto theend; + } + else if (**arg == 'w') + { + semsg("Namespace w: not supported yet: %s", *arg); + goto theend; + } + else if (**arg == 't') + { + semsg("Namespace t: not supported yet: %s", *arg); + goto theend; + } else { ! semsg("E1075: Namespace not supported: %s", *arg); goto theend; } } *************** *** 2060,2065 **** --- 2078,2084 ---- } else if (p == arg && *arg == '#' && arg[1] == '{') { + // Can be "#{a: 1}->Func()". ++p; if (eval_dict(&p, &rettv, FALSE, TRUE) == FAIL) p = arg; *************** *** 2068,2073 **** --- 2087,2094 ---- { int ret = get_lambda_tv(&p, &rettv, FALSE); + // Can be "{x -> ret}()". + // Can be "{'a': 1}->Func()". if (ret == NOTDONE) ret = eval_dict(&p, &rettv, FALSE, FALSE); if (ret != OK) *************** *** 5123,5129 **** } // "{" starts a block scope ! if (*ea.cmd == '{') { line = compile_block(ea.cmd, &cctx); continue; --- 5144,5151 ---- } // "{" starts a block scope ! // "{'a': 1}->func() is something else ! if (*ea.cmd == '{' && ends_excmd(*skipwhite(ea.cmd + 1))) { line = compile_block(ea.cmd, &cctx); continue; *** ../vim-8.2.0466/src/scriptfile.c 2020-03-20 18:39:42.977273186 +0100 --- src/scriptfile.c 2020-03-28 16:14:02.201209267 +0100 *************** *** 1274,1279 **** --- 1274,1280 ---- // loading the same script again si->sn_had_command = FALSE; + si->sn_version = 1; current_sctx.sc_sid = sid; ht = &SCRIPT_VARS(sid); *** ../vim-8.2.0466/src/dict.c 2020-01-26 15:52:33.015833276 +0100 --- src/dict.c 2020-03-28 19:12:19.653106924 +0100 *************** *** 826,832 **** if (**arg != ':') { ! semsg(_(e_missing_dict_colon), *arg); clear_tv(&tvkey); goto failret; } --- 826,833 ---- if (**arg != ':') { ! if (evaluate) ! semsg(_(e_missing_dict_colon), *arg); clear_tv(&tvkey); goto failret; } *************** *** 853,859 **** item = dict_find(d, key, -1); if (item != NULL) { ! semsg(_(e_duplicate_key), key); clear_tv(&tvkey); clear_tv(&tv); goto failret; --- 854,861 ---- item = dict_find(d, key, -1); if (item != NULL) { ! if (evaluate) ! semsg(_(e_duplicate_key), key); clear_tv(&tvkey); clear_tv(&tv); goto failret; *************** *** 873,879 **** break; if (**arg != ',') { ! semsg(_(e_missing_dict_comma), *arg); goto failret; } *arg = skipwhite(*arg + 1); --- 875,882 ---- break; if (**arg != ',') { ! if (evaluate) ! semsg(_(e_missing_dict_comma), *arg); goto failret; } *arg = skipwhite(*arg + 1); *************** *** 881,887 **** if (**arg != '}') { ! semsg(_(e_missing_dict_end), *arg); failret: if (d != NULL) dict_free(d); --- 884,891 ---- if (**arg != '}') { ! if (evaluate) ! semsg(_(e_missing_dict_end), *arg); failret: if (d != NULL) dict_free(d); *** ../vim-8.2.0466/src/testdir/test_vim9_expr.vim 2020-03-02 22:53:28.460549750 +0100 --- src/testdir/test_vim9_expr.vim 2020-03-28 19:39:24.528242249 +0100 *************** *** 812,823 **** --- 812,836 ---- call CheckDefExecFailure("echo s:doesnt_exist", 'E121:') call CheckDefExecFailure("echo g:doesnt_exist", 'E121:') + call CheckDefFailure("echo a:somevar", 'E1075:') + call CheckDefFailure("echo l:somevar", 'E1075:') + call CheckDefFailure("echo x:somevar", 'E1075:') + + " TODO + call CheckDefFailure("echo b:somevar", 'not supported yet') + call CheckDefFailure("echo w:somevar", 'not supported yet') + call CheckDefFailure("echo t:somevar", 'not supported yet') + call CheckDefExecFailure("let x = +g:astring", 'E1030:') call CheckDefExecFailure("let x = +g:ablob", 'E974:') call CheckDefExecFailure("let x = +g:alist", 'E745:') call CheckDefExecFailure("let x = +g:adict", 'E728:') call CheckDefFailureMult(["let x = ''", "let y = x.memb"], 'E715:') + + call CheckDefExecFailure("[1, 2->len()", 'E492:') + call CheckDefExecFailure("#{a: 1->len()", 'E488:') + call CheckDefExecFailure("{'a': 1->len()", 'E492:') endfunc let g:Funcrefs = [function('add')] *************** *** 878,881 **** --- 891,898 ---- call CheckDefFailure("v:nosuch += 3", 'E1001:') call CheckDefFailure("let v:version = 3", 'E1064:') call CheckDefFailure("let asdf = v:nosuch", 'E1001:') + + call CheckDefFailure("echo len('asdf'", 'E110:') + call CheckDefFailure("echo Func0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()", 'E1011:') + call CheckDefFailure("echo doesnotexist()", 'E117:') endfunc *** ../vim-8.2.0466/src/testdir/test_vim9_script.vim 2020-03-28 14:53:17.104420156 +0100 --- src/testdir/test_vim9_script.vim 2020-03-28 19:31:02.086107472 +0100 *************** *** 101,106 **** --- 101,108 ---- call CheckDefFailure(['let true = 1'], 'E1034:') call CheckDefFailure(['let false = 1'], 'E1034:') + call CheckScriptFailure(['vim9script', 'def Func()', 'let dummy = s:notfound', 'enddef'], 'E1050:') + call CheckDefFailure(['let var: list = [123]'], 'expected list but got list') call CheckDefFailure(['let var: list = ["xx"]'], 'expected list but got list') *************** *** 618,623 **** --- 620,631 ---- enddef {'a': 1, 'b': 2}->DictFunc() assert_equal(#{a: 1, b: 2}, dictvar) + def CompiledDict() + {'a': 3, 'b': 4}->DictFunc() + enddef + CompiledDict() + assert_equal(#{a: 3, b: 4}, dictvar) + #{a: 3, b: 4}->DictFunc() assert_equal(#{a: 3, b: 4}, dictvar) *** ../vim-8.2.0466/src/version.c 2020-03-28 18:06:25.751664246 +0100 --- src/version.c 2020-03-28 19:39:53.348132621 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 467, /**/ -- FATHER: We are here today to witness the union of two young people in the joyful bond of the holy wedlock. Unfortunately, one of them, my son Herbert, has just fallen to his death. [Murmurs from CROWD; the BRIDE smiles with relief, coughs.] "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///