To: vim_dev@googlegroups.com Subject: Patch 8.2.0640 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0640 Problem: Vim9: expanding `=expr` does not work. Solution: Find wildcards in not compiled commands. Reorganize test files. Files: Filelist, src/vim9.h, src/vim9compile.c, src/vim9execute.c, src/testdir/vim9.vim, src/testdir/test_vim9_cmd.vim, src/testdir/test_vim9_disassemble.vim, src/testdir/test_vim9_expr.vim, src/testdir/test_vim9_script.vim, src/testdir/Make_all.mak *** ../vim-8.2.0639/Filelist 2020-04-23 15:41:21.867364624 +0200 --- Filelist 2020-04-25 20:01:55.765181634 +0200 *************** *** 162,167 **** --- 162,168 ---- src/testdir/setup.vim \ src/testdir/setup_gui.vim \ src/testdir/shared.vim \ + src/testdir/vim9.vim \ src/testdir/summarize.vim \ src/testdir/term_util.vim \ src/testdir/view_util.vim \ *** ../vim-8.2.0639/src/vim9.h 2020-04-23 22:16:49.763270683 +0200 --- src/vim9.h 2020-04-25 19:00:32.517502986 +0200 *************** *** 13,18 **** --- 13,19 ---- typedef enum { ISN_EXEC, // execute Ex command line isn_arg.string + ISN_EXECCONCAT, // execute Ex command from isn_arg.number items on stack ISN_ECHO, // echo isn_arg.echo.echo_count items on top of stack ISN_EXECUTE, // execute Ex commands isn_arg.number items on top of stack ISN_ECHOMSG, // echo Ex commands isn_arg.number items on top of stack *** ../vim-8.2.0639/src/vim9compile.c 2020-04-23 22:16:49.763270683 +0200 --- src/vim9compile.c 2020-04-25 19:41:07.767369431 +0200 *************** *** 1427,1432 **** --- 1427,1443 ---- return OK; } + static int + generate_EXECCONCAT(cctx_T *cctx, int count) + { + isn_T *isn; + + if ((isn = generate_instr_drop(cctx, ISN_EXECCONCAT, count)) == NULL) + return FAIL; + isn->isn_arg.number = count; + return OK; + } + /* * Reserve space for a local variable. * Return the index or -1 if it failed. *************** *** 5805,5810 **** --- 5816,5886 ---- } /* + * A command that is not compiled, execute with legacy code. + */ + static char_u * + compile_exec(char_u *line, exarg_T *eap, cctx_T *cctx) + { + char_u *p; + + if (cctx->ctx_skip == TRUE) + goto theend; + + + if ((excmd_get_argt(eap->cmdidx) & EX_XFILE) + && (p = (char_u *)strstr((char *)eap->arg, "`=")) != NULL) + { + int count = 0; + char_u *start = skipwhite(line); + + // :cmd xxx`=expr1`yyy`=expr2`zzz + // PUSHS ":cmd xxx" + // eval expr1 + // PUSHS "yyy" + // eval expr2 + // PUSHS "zzz" + // EXECCONCAT 5 + for (;;) + { + if (p > start) + { + generate_PUSHS(cctx, vim_strnsave(start, (int)(p - start))); + ++count; + } + p += 2; + if (compile_expr1(&p, cctx) == FAIL) + return NULL; + may_generate_2STRING(-1, cctx); + ++count; + p = skipwhite(p); + if (*p != '`') + { + emsg(_("E1083: missing backtick")); + return NULL; + } + start = p + 1; + + p = (char_u *)strstr((char *)start, "`="); + if (p == NULL) + { + if (*skipwhite(start) != NUL) + { + generate_PUSHS(cctx, vim_strsave(start)); + ++count; + } + break; + } + } + generate_EXECCONCAT(cctx, count); + } + else + generate_EXEC(cctx, line); + + theend: + return (char_u *)""; + } + + /* * After ex_function() has collected all the function lines: parse and compile * the lines into instructions. * Adds the function to "def_functions". *************** *** 5818,5824 **** { char_u *line = NULL; char_u *p; - exarg_T ea; char *errormsg = NULL; // error message int had_return = FALSE; cctx_T cctx; --- 5894,5899 ---- *************** *** 5917,5922 **** --- 5992,5998 ---- */ for (;;) { + exarg_T ea; int is_ex_command = FALSE; // Bail out on the first error to avoid a flood of errors and report *************** *** 5952,5958 **** switch (*ea.cmd) { case '#': ! // "#" starts a comment, but not "#{". if (ea.cmd[1] != '{') { line = (char_u *)""; --- 6028,6034 ---- switch (*ea.cmd) { case '#': ! // "#" starts a comment, but "#{" does not. if (ea.cmd[1] != '{') { line = (char_u *)""; *************** *** 6093,6099 **** && ea.cmdidx != CMD_else && ea.cmdidx != CMD_endif) { ! line += STRLEN(line); continue; } --- 6169,6175 ---- && ea.cmdidx != CMD_else && ea.cmdidx != CMD_endif) { ! line = (char_u *)""; continue; } *************** *** 6183,6192 **** break; default: - // Not recognized, execute with do_cmdline_cmd(). // TODO: other commands with an expression argument ! generate_EXEC(&cctx, line); ! line = (char_u *)""; break; } if (line == NULL) --- 6259,6268 ---- break; default: // TODO: other commands with an expression argument ! // Not recognized, execute with do_cmdline_cmd(). ! ea.arg = p; ! line = compile_exec(line, &ea, &cctx); break; } if (line == NULL) *************** *** 6401,6410 **** case ISN_DCALL: case ISN_DROP: case ISN_ECHO: - case ISN_EXECUTE: - case ISN_ECHOMSG: case ISN_ECHOERR: case ISN_ENDTRY: case ISN_FOR: case ISN_FUNCREF: case ISN_INDEX: --- 6477,6487 ---- case ISN_DCALL: case ISN_DROP: case ISN_ECHO: case ISN_ECHOERR: + case ISN_ECHOMSG: case ISN_ENDTRY: + case ISN_EXECCONCAT: + case ISN_EXECUTE: case ISN_FOR: case ISN_FUNCREF: case ISN_INDEX: *** ../vim-8.2.0639/src/vim9execute.c 2020-04-23 22:16:49.763270683 +0200 --- src/vim9execute.c 2020-04-25 19:37:26.131506402 +0200 *************** *** 648,653 **** --- 648,692 ---- do_cmdline_cmd(iptr->isn_arg.string); break; + // execute Ex command from pieces on the stack + case ISN_EXECCONCAT: + { + int count = iptr->isn_arg.number; + int len = 0; + int pass; + int i; + char_u *cmd = NULL; + char_u *str; + + for (pass = 1; pass <= 2; ++pass) + { + for (i = 0; i < count; ++i) + { + tv = STACK_TV_BOT(i - count); + str = tv->vval.v_string; + if (str != NULL && *str != NUL) + { + if (pass == 2) + STRCPY(cmd + len, str); + len += STRLEN(str); + } + if (pass == 2) + clear_tv(tv); + } + if (pass == 1) + { + cmd = alloc(len + 1); + if (cmd == NULL) + goto failed; + len = 0; + } + } + + do_cmdline_cmd(cmd); + vim_free(cmd); + } + break; + // execute :echo {string} ... case ISN_ECHO: { *************** *** 1961,1966 **** --- 2000,2009 ---- case ISN_EXEC: smsg("%4d EXEC %s", current, iptr->isn_arg.string); break; + case ISN_EXECCONCAT: + smsg("%4d EXECCONCAT %lld", current, + (long long)iptr->isn_arg.number); + break; case ISN_ECHO: { echo_T *echo = &iptr->isn_arg.echo; *** ../vim-8.2.0639/src/testdir/vim9.vim 2020-04-25 20:00:47.577325747 +0200 --- src/testdir/vim9.vim 2020-04-25 18:19:28.903693850 +0200 *************** *** 0 **** --- 1,28 ---- + " Utility functions for testing vim9 script + + " Check that "lines" inside ":def" results in an "error" message. + func CheckDefFailure(lines, error) + call writefile(['def Func()'] + a:lines + ['enddef'], 'Xdef') + call assert_fails('so Xdef', a:error, a:lines) + call delete('Xdef') + endfunc + + def CheckScriptFailure(lines: list, error: string) + writefile(lines, 'Xdef') + assert_fails('so Xdef', error, lines) + delete('Xdef') + enddef + + def CheckScriptSuccess(lines: list) + writefile(lines, 'Xdef') + so Xdef + delete('Xdef') + enddef + + " Check that "line" inside ":def" results in an "error" message when executed. + func CheckDefExecFailure(line, error) + call writefile(['def! Func()', a:line, 'enddef'], 'Xdef') + so Xdef + call assert_fails('call Func()', a:error, a:line) + call delete('Xdef') + endfunc *** ../vim-8.2.0639/src/testdir/test_vim9_cmd.vim 2020-04-25 20:00:47.581325736 +0200 --- src/testdir/test_vim9_cmd.vim 2020-04-25 19:55:34.373970302 +0200 *************** *** 0 **** --- 1,23 ---- + " Test commands that are not compiled in a :def function + + source vim9.vim + + def Test_edit_wildcards() + let filename = 'Xtest' + edit `=filename` + assert_equal('Xtest', bufname()) + + let filenr = 123 + edit Xtest`=filenr` + assert_equal('Xtest123', bufname()) + + filenr = 77 + edit `=filename``=filenr` + assert_equal('Xtest77', bufname()) + + edit X`=filename`xx`=filenr`yy + assert_equal('XXtestxx77yy', bufname()) + enddef + + + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker *** ../vim-8.2.0639/src/testdir/test_vim9_disassemble.vim 2020-04-23 22:16:49.767270674 +0200 --- src/testdir/test_vim9_disassemble.vim 2020-04-25 19:49:44.798633701 +0200 *************** *** 53,58 **** --- 53,84 ---- res) enddef + def s:EditExpand() + let filename = "file" + let filenr = 123 + edit the`=filename``=filenr`.txt + enddef + + def Test_disassemble_exec_expr() + let res = execute('disass s:EditExpand') + assert_match('\d*_EditExpand.*' .. + ' let filename = "file".*' .. + '\d PUSHS "file".*' .. + '\d STORE $0.*' .. + ' let filenr = 123.*' .. + '\d STORE 123 in $1.*' .. + ' edit the`=filename``=filenr`.txt.*' .. + '\d PUSHS "edit the".*' .. + '\d LOAD $0.*' .. + '\d LOAD $1.*' .. + '\d 2STRING stack\[-1\].*' .. + '\d PUSHS ".txt".*' .. + '\d EXECCONCAT 4.*' .. + '\d PUSHNR 0.*' .. + '\d RETURN', + res) + enddef + def s:ScriptFuncPush() let localbool = true let localspec = v:none *** ../vim-8.2.0639/src/testdir/test_vim9_expr.vim 2020-04-19 14:32:13.556206438 +0200 --- src/testdir/test_vim9_expr.vim 2020-04-25 18:22:16.759328385 +0200 *************** *** 1,33 **** " Tests for Vim9 script expressions source check.vim ! ! " Check that "line" inside ":def" results in an "error" message. ! func CheckDefFailure(line, error) ! call writefile(['def! Func()', a:line, 'enddef'], 'Xdef') ! call assert_fails('so Xdef', a:error, a:line) ! call delete('Xdef') ! endfunc ! ! func CheckDefFailureMult(lines, error) ! call writefile(['def! Func()'] + a:lines + ['enddef'], 'Xdef') ! call assert_fails('so Xdef', a:error, join(a:lines, ' | ')) ! call delete('Xdef') ! endfunc ! ! " Check that "line" inside ":def" results in an "error" message when executed. ! func CheckDefExecFailure(line, error) ! call writefile(['def! Func()', a:line, 'enddef'], 'Xdef') ! so Xdef ! call assert_fails('call Func()', a:error, a:line) ! call delete('Xdef') ! endfunc ! ! func CheckDefFailureList(lines, error) ! call writefile(['def! Func()'] + a:lines + ['enddef'], 'Xdef') ! call assert_fails('so Xdef', a:error, string(a:lines)) ! call delete('Xdef') ! endfunc " test cond ? expr : expr def Test_expr1() --- 1,7 ---- " Tests for Vim9 script expressions source check.vim ! source vim9.vim " test cond ? expr : expr def Test_expr1() *************** *** 59,76 **** enddef func Test_expr1_fails() ! call CheckDefFailure("let x = 1 ? 'one'", "Missing ':' after '?'") ! call CheckDefFailure("let x = 1 ? 'one' : xxx", "E1001:") let msg = "white space required before and after '?'" ! call CheckDefFailure("let x = 1? 'one' : 'two'", msg) ! call CheckDefFailure("let x = 1 ?'one' : 'two'", msg) ! call CheckDefFailure("let x = 1?'one' : 'two'", msg) let msg = "white space required before and after ':'" ! call CheckDefFailure("let x = 1 ? 'one': 'two'", msg) ! call CheckDefFailure("let x = 1 ? 'one' :'two'", msg) ! call CheckDefFailure("let x = 1 ? 'one':'two'", msg) endfunc " TODO: define inside test function --- 33,50 ---- enddef func Test_expr1_fails() ! call CheckDefFailure(["let x = 1 ? 'one'"], "Missing ':' after '?'") ! call CheckDefFailure(["let x = 1 ? 'one' : xxx"], "E1001:") let msg = "white space required before and after '?'" ! call CheckDefFailure(["let x = 1? 'one' : 'two'"], msg) ! call CheckDefFailure(["let x = 1 ?'one' : 'two'"], msg) ! call CheckDefFailure(["let x = 1?'one' : 'two'"], msg) let msg = "white space required before and after ':'" ! call CheckDefFailure(["let x = 1 ? 'one': 'two'"], msg) ! call CheckDefFailure(["let x = 1 ? 'one' :'two'"], msg) ! call CheckDefFailure(["let x = 1 ? 'one':'two'"], msg) endfunc " TODO: define inside test function *************** *** 107,117 **** func Test_expr2_fails() let msg = "white space required before and after '||'" ! call CheckDefFailure("let x = 1||2", msg) ! call CheckDefFailure("let x = 1 ||2", msg) ! call CheckDefFailure("let x = 1|| 2", msg) ! call CheckDefFailure("let x = 1 || xxx", 'E1001:') endfunc " test && --- 81,91 ---- func Test_expr2_fails() let msg = "white space required before and after '||'" ! call CheckDefFailure(["let x = 1||2"], msg) ! call CheckDefFailure(["let x = 1 ||2"], msg) ! call CheckDefFailure(["let x = 1|| 2"], msg) ! call CheckDefFailure(["let x = 1 || xxx"], 'E1001:') endfunc " test && *************** *** 148,156 **** func Test_expr3_fails() let msg = "white space required before and after '&&'" ! call CheckDefFailure("let x = 1&&2", msg) ! call CheckDefFailure("let x = 1 &&2", msg) ! call CheckDefFailure("let x = 1&& 2", msg) endfunc let atrue = v:true --- 122,130 ---- func Test_expr3_fails() let msg = "white space required before and after '&&'" ! call CheckDefFailure(["let x = 1&&2"], msg) ! call CheckDefFailure(["let x = 1 &&2"], msg) ! call CheckDefFailure(["let x = 1&& 2"], msg) endfunc let atrue = v:true *************** *** 212,218 **** assert_equal(false, 'abc' ==# 'ABC') set noignorecase ! call CheckDefFailure("let x = 'a' == xxx", 'E1001:') assert_equal(true, 0z3f == 0z3f) assert_equal(false, 0z3f == 0z4f) --- 186,192 ---- assert_equal(false, 'abc' ==# 'ABC') set noignorecase ! call CheckDefFailure(["let x = 'a' == xxx"], 'E1001:') assert_equal(true, 0z3f == 0z3f) assert_equal(false, 0z3f == 0z4f) *************** *** 413,483 **** func Test_expr4_fails() let msg = "white space required before and after '>'" ! call CheckDefFailure("let x = 1>2", msg) ! call CheckDefFailure("let x = 1 >2", msg) ! call CheckDefFailure("let x = 1> 2", msg) let msg = "white space required before and after '=='" ! call CheckDefFailure("let x = 1==2", msg) ! call CheckDefFailure("let x = 1 ==2", msg) ! call CheckDefFailure("let x = 1== 2", msg) let msg = "white space required before and after 'is'" ! call CheckDefFailure("let x = '1'is'2'", msg) ! call CheckDefFailure("let x = '1' is'2'", msg) ! call CheckDefFailure("let x = '1'is '2'", msg) let msg = "white space required before and after 'isnot'" ! call CheckDefFailure("let x = '1'isnot'2'", msg) ! call CheckDefFailure("let x = '1' isnot'2'", msg) ! call CheckDefFailure("let x = '1'isnot '2'", msg) ! ! call CheckDefFailure("let x = 1 is# 2", 'E15:') ! call CheckDefFailure("let x = 1 is? 2", 'E15:') ! call CheckDefFailure("let x = 1 isnot# 2", 'E15:') ! call CheckDefFailure("let x = 1 isnot? 2", 'E15:') ! ! call CheckDefFailure("let x = 1 == '2'", 'Cannot compare number with string') ! call CheckDefFailure("let x = '1' == 2", 'Cannot compare string with number') ! call CheckDefFailure("let x = 1 == RetVoid()", 'Cannot use void value') ! call CheckDefFailure("let x = RetVoid() == 1", 'Cannot compare void with number') ! ! call CheckDefFailure("let x = true > false", 'Cannot compare bool with bool') ! call CheckDefFailure("let x = true >= false", 'Cannot compare bool with bool') ! call CheckDefFailure("let x = true < false", 'Cannot compare bool with bool') ! call CheckDefFailure("let x = true <= false", 'Cannot compare bool with bool') ! call CheckDefFailure("let x = true =~ false", 'Cannot compare bool with bool') ! call CheckDefFailure("let x = true !~ false", 'Cannot compare bool with bool') ! call CheckDefFailure("let x = true is false", 'Cannot use "is" with bool') ! call CheckDefFailure("let x = true isnot false", 'Cannot use "isnot" with bool') ! ! call CheckDefFailure("let x = v:none is v:null", 'Cannot use "is" with special') ! call CheckDefFailure("let x = v:none isnot v:null", 'Cannot use "isnot" with special') ! call CheckDefFailure("let x = 123 is 123", 'Cannot use "is" with number') ! call CheckDefFailure("let x = 123 isnot 123", 'Cannot use "isnot" with number') ! if has('float') ! call CheckDefFailure("let x = 1.3 is 1.3", 'Cannot use "is" with float') ! call CheckDefFailure("let x = 1.3 isnot 1.3", 'Cannot use "isnot" with float') ! endif ! ! call CheckDefFailure("let x = 0za1 > 0z34", 'Cannot compare blob with blob') ! call CheckDefFailure("let x = 0za1 >= 0z34", 'Cannot compare blob with blob') ! call CheckDefFailure("let x = 0za1 < 0z34", 'Cannot compare blob with blob') ! call CheckDefFailure("let x = 0za1 <= 0z34", 'Cannot compare blob with blob') ! call CheckDefFailure("let x = 0za1 =~ 0z34", 'Cannot compare blob with blob') ! call CheckDefFailure("let x = 0za1 !~ 0z34", 'Cannot compare blob with blob') ! ! call CheckDefFailure("let x = [13] > [88]", 'Cannot compare list with list') ! call CheckDefFailure("let x = [13] >= [88]", 'Cannot compare list with list') ! call CheckDefFailure("let x = [13] < [88]", 'Cannot compare list with list') ! call CheckDefFailure("let x = [13] <= [88]", 'Cannot compare list with list') ! call CheckDefFailure("let x = [13] =~ [88]", 'Cannot compare list with list') ! call CheckDefFailure("let x = [13] !~ [88]", 'Cannot compare list with list') ! ! call CheckDefFailureMult(['let j: job', 'let chan: channel', 'let r = j == chan'], 'Cannot compare job with channel') ! call CheckDefFailureMult(['let j: job', 'let x: list', 'let r = j == x'], 'Cannot compare job with list') ! call CheckDefFailureMult(['let j: job', 'let Xx: func', 'let r = j == Xx'], 'Cannot compare job with func') ! call CheckDefFailureMult(['let j: job', 'let Xx: func', 'let r = j == Xx'], 'Cannot compare job with func') endfunc " test addition, subtraction, concatenation --- 387,457 ---- func Test_expr4_fails() let msg = "white space required before and after '>'" ! call CheckDefFailure(["let x = 1>2"], msg) ! call CheckDefFailure(["let x = 1 >2"], msg) ! call CheckDefFailure(["let x = 1> 2"], msg) let msg = "white space required before and after '=='" ! call CheckDefFailure(["let x = 1==2"], msg) ! call CheckDefFailure(["let x = 1 ==2"], msg) ! call CheckDefFailure(["let x = 1== 2"], msg) let msg = "white space required before and after 'is'" ! call CheckDefFailure(["let x = '1'is'2'"], msg) ! call CheckDefFailure(["let x = '1' is'2'"], msg) ! call CheckDefFailure(["let x = '1'is '2'"], msg) let msg = "white space required before and after 'isnot'" ! call CheckDefFailure(["let x = '1'isnot'2'"], msg) ! call CheckDefFailure(["let x = '1' isnot'2'"], msg) ! call CheckDefFailure(["let x = '1'isnot '2'"], msg) ! ! call CheckDefFailure(["let x = 1 is# 2"], 'E15:') ! call CheckDefFailure(["let x = 1 is? 2"], 'E15:') ! call CheckDefFailure(["let x = 1 isnot# 2"], 'E15:') ! call CheckDefFailure(["let x = 1 isnot? 2"], 'E15:') ! ! call CheckDefFailure(["let x = 1 == '2'"], 'Cannot compare number with string') ! call CheckDefFailure(["let x = '1' == 2"], 'Cannot compare string with number') ! call CheckDefFailure(["let x = 1 == RetVoid()"], 'Cannot use void value') ! call CheckDefFailure(["let x = RetVoid() == 1"], 'Cannot compare void with number') ! ! call CheckDefFailure(["let x = true > false"], 'Cannot compare bool with bool') ! call CheckDefFailure(["let x = true >= false"], 'Cannot compare bool with bool') ! call CheckDefFailure(["let x = true < false"], 'Cannot compare bool with bool') ! call CheckDefFailure(["let x = true <= false"], 'Cannot compare bool with bool') ! call CheckDefFailure(["let x = true =~ false"], 'Cannot compare bool with bool') ! call CheckDefFailure(["let x = true !~ false"], 'Cannot compare bool with bool') ! call CheckDefFailure(["let x = true is false"], 'Cannot use "is" with bool') ! call CheckDefFailure(["let x = true isnot false"], 'Cannot use "isnot" with bool') ! ! call CheckDefFailure(["let x = v:none is v:null"], 'Cannot use "is" with special') ! call CheckDefFailure(["let x = v:none isnot v:null"], 'Cannot use "isnot" with special') ! call CheckDefFailure(["let x = 123 is 123"], 'Cannot use "is" with number') ! call CheckDefFailure(["let x = 123 isnot 123"], 'Cannot use "isnot" with number') ! if has('float') ! call CheckDefFailure(["let x = 1.3 is 1.3"], 'Cannot use "is" with float') ! call CheckDefFailure(["let x = 1.3 isnot 1.3"], 'Cannot use "isnot" with float') ! endif ! ! call CheckDefFailure(["let x = 0za1 > 0z34"], 'Cannot compare blob with blob') ! call CheckDefFailure(["let x = 0za1 >= 0z34"], 'Cannot compare blob with blob') ! call CheckDefFailure(["let x = 0za1 < 0z34"], 'Cannot compare blob with blob') ! call CheckDefFailure(["let x = 0za1 <= 0z34"], 'Cannot compare blob with blob') ! call CheckDefFailure(["let x = 0za1 =~ 0z34"], 'Cannot compare blob with blob') ! call CheckDefFailure(["let x = 0za1 !~ 0z34"], 'Cannot compare blob with blob') ! ! call CheckDefFailure(["let x = [13] > [88]"], 'Cannot compare list with list') ! call CheckDefFailure(["let x = [13] >= [88]"], 'Cannot compare list with list') ! call CheckDefFailure(["let x = [13] < [88]"], 'Cannot compare list with list') ! call CheckDefFailure(["let x = [13] <= [88]"], 'Cannot compare list with list') ! call CheckDefFailure(["let x = [13] =~ [88]"], 'Cannot compare list with list') ! call CheckDefFailure(["let x = [13] !~ [88]"], 'Cannot compare list with list') ! ! call CheckDefFailure(['let j: job', 'let chan: channel', 'let r = j == chan'], 'Cannot compare job with channel') ! call CheckDefFailure(['let j: job', 'let x: list', 'let r = j == x'], 'Cannot compare job with list') ! call CheckDefFailure(['let j: job', 'let Xx: func', 'let r = j == Xx'], 'Cannot compare job with func') ! call CheckDefFailure(['let j: job', 'let Xx: func', 'let r = j == Xx'], 'Cannot compare job with func') endfunc " test addition, subtraction, concatenation *************** *** 532,558 **** func Test_expr5_fails() let msg = "white space required before and after '+'" ! call CheckDefFailure("let x = 1+2", msg) ! call CheckDefFailure("let x = 1 +2", msg) ! call CheckDefFailure("let x = 1+ 2", msg) let msg = "white space required before and after '-'" ! call CheckDefFailure("let x = 1-2", msg) ! call CheckDefFailure("let x = 1 -2", msg) ! call CheckDefFailure("let x = 1- 2", msg) let msg = "white space required before and after '..'" ! call CheckDefFailure("let x = '1'..'2'", msg) ! call CheckDefFailure("let x = '1' ..'2'", msg) ! call CheckDefFailure("let x = '1'.. '2'", msg) ! ! call CheckDefFailure("let x = 0z1122 + 33", 'E1035') ! call CheckDefFailure("let x = 0z1122 + [3]", 'E1035') ! call CheckDefFailure("let x = 0z1122 + 'asd'", 'E1035') ! call CheckDefFailure("let x = 33 + 0z1122", 'E1035') ! call CheckDefFailure("let x = [3] + 0z1122", 'E1035') ! call CheckDefFailure("let x = 'asdf' + 0z1122", 'E1035') ! call CheckDefFailure("let x = 6 + xxx", 'E1001') endfunc " test multiply, divide, modulo --- 506,532 ---- func Test_expr5_fails() let msg = "white space required before and after '+'" ! call CheckDefFailure(["let x = 1+2"], msg) ! call CheckDefFailure(["let x = 1 +2"], msg) ! call CheckDefFailure(["let x = 1+ 2"], msg) let msg = "white space required before and after '-'" ! call CheckDefFailure(["let x = 1-2"], msg) ! call CheckDefFailure(["let x = 1 -2"], msg) ! call CheckDefFailure(["let x = 1- 2"], msg) let msg = "white space required before and after '..'" ! call CheckDefFailure(["let x = '1'..'2'"], msg) ! call CheckDefFailure(["let x = '1' ..'2'"], msg) ! call CheckDefFailure(["let x = '1'.. '2'"], msg) ! ! call CheckDefFailure(["let x = 0z1122 + 33"], 'E1035') ! call CheckDefFailure(["let x = 0z1122 + [3]"], 'E1035') ! call CheckDefFailure(["let x = 0z1122 + 'asd'"], 'E1035') ! call CheckDefFailure(["let x = 33 + 0z1122"], 'E1035') ! call CheckDefFailure(["let x = [3] + 0z1122"], 'E1035') ! call CheckDefFailure(["let x = 'asdf' + 0z1122"], 'E1035') ! call CheckDefFailure(["let x = 6 + xxx"], 'E1001') endfunc " test multiply, divide, modulo *************** *** 588,594 **** assert_equal(6.0, xf[0] * yf[0]) endif ! call CheckDefFailure("let x = 6 * xxx", 'E1001') enddef def Test_expr6_float() --- 562,568 ---- assert_equal(6.0, xf[0] * yf[0]) endif ! call CheckDefFailure(["let x = 6 * xxx"], 'E1001') enddef def Test_expr6_float() *************** *** 623,667 **** func Test_expr6_fails() let msg = "white space required before and after '*'" ! call CheckDefFailure("let x = 1*2", msg) ! call CheckDefFailure("let x = 1 *2", msg) ! call CheckDefFailure("let x = 1* 2", msg) let msg = "white space required before and after '/'" ! call CheckDefFailure("let x = 1/2", msg) ! call CheckDefFailure("let x = 1 /2", msg) ! call CheckDefFailure("let x = 1/ 2", msg) let msg = "white space required before and after '%'" ! call CheckDefFailure("let x = 1%2", msg) ! call CheckDefFailure("let x = 1 %2", msg) ! call CheckDefFailure("let x = 1% 2", msg) ! call CheckDefFailure("let x = '1' * '2'", 'E1036:') ! call CheckDefFailure("let x = '1' / '2'", 'E1036:') ! call CheckDefFailure("let x = '1' % '2'", 'E1035:') ! call CheckDefFailure("let x = 0z01 * 0z12", 'E1036:') ! call CheckDefFailure("let x = 0z01 / 0z12", 'E1036:') ! call CheckDefFailure("let x = 0z01 % 0z12", 'E1035:') ! call CheckDefFailure("let x = [1] * [2]", 'E1036:') ! call CheckDefFailure("let x = [1] / [2]", 'E1036:') ! call CheckDefFailure("let x = [1] % [2]", 'E1035:') ! call CheckDefFailure("let x = #{one: 1} * #{two: 2}", 'E1036:') ! call CheckDefFailure("let x = #{one: 1} / #{two: 2}", 'E1036:') ! call CheckDefFailure("let x = #{one: 1} % #{two: 2}", 'E1035:') ! call CheckDefFailure("let x = 0xff[1]", 'E714:') if has('float') ! call CheckDefFailure("let x = 0.7[1]", 'E714:') endif endfunc func Test_expr6_float_fails() CheckFeature float ! call CheckDefFailure("let x = 1.0 % 2", 'E1035:') endfunc " define here to use old style parsing --- 597,641 ---- func Test_expr6_fails() let msg = "white space required before and after '*'" ! call CheckDefFailure(["let x = 1*2"], msg) ! call CheckDefFailure(["let x = 1 *2"], msg) ! call CheckDefFailure(["let x = 1* 2"], msg) let msg = "white space required before and after '/'" ! call CheckDefFailure(["let x = 1/2"], msg) ! call CheckDefFailure(["let x = 1 /2"], msg) ! call CheckDefFailure(["let x = 1/ 2"], msg) let msg = "white space required before and after '%'" ! call CheckDefFailure(["let x = 1%2"], msg) ! call CheckDefFailure(["let x = 1 %2"], msg) ! call CheckDefFailure(["let x = 1% 2"], msg) ! call CheckDefFailure(["let x = '1' * '2'"], 'E1036:') ! call CheckDefFailure(["let x = '1' / '2'"], 'E1036:') ! call CheckDefFailure(["let x = '1' % '2'"], 'E1035:') ! call CheckDefFailure(["let x = 0z01 * 0z12"], 'E1036:') ! call CheckDefFailure(["let x = 0z01 / 0z12"], 'E1036:') ! call CheckDefFailure(["let x = 0z01 % 0z12"], 'E1035:') ! call CheckDefFailure(["let x = [1] * [2]"], 'E1036:') ! call CheckDefFailure(["let x = [1] / [2]"], 'E1036:') ! call CheckDefFailure(["let x = [1] % [2]"], 'E1035:') ! call CheckDefFailure(["let x = #{one: 1} * #{two: 2}"], 'E1036:') ! call CheckDefFailure(["let x = #{one: 1} / #{two: 2}"], 'E1036:') ! call CheckDefFailure(["let x = #{one: 1} % #{two: 2}"], 'E1035:') ! call CheckDefFailure(["let x = 0xff[1]"], 'E714:') if has('float') ! call CheckDefFailure(["let x = 0.7[1]"], 'E714:') endif endfunc func Test_expr6_float_fails() CheckFeature float ! call CheckDefFailure(["let x = 1.0 % 2"], 'E1035:') endfunc " define here to use old style parsing *************** *** 721,727 **** assert_equal(g:blob_one, 0z01) assert_equal(g:blob_long, 0z0102.0304) ! call CheckDefFailure("let x = 0z123", 'E973:') enddef def Test_expr7_string() --- 695,701 ---- assert_equal(g:blob_one, 0z01) assert_equal(g:blob_long, 0z0102.0304) ! call CheckDefFailure(["let x = 0z123"], 'E973:') enddef def Test_expr7_string() *************** *** 734,749 **** assert_equal(g:string_long, "abcdefghijklm") assert_equal(g:string_special, "ab\ncd\ref\ekk") ! call CheckDefFailure('let x = "abc', 'E114:') ! call CheckDefFailure("let x = 'abc", 'E115:') enddef def Test_expr7_vimvar() let old: list = v:oldfiles let compl: dict = v:completed_item ! call CheckDefFailure("let old: list = v:oldfiles", 'E1013: type mismatch, expected list but got list') ! call CheckDefFailure("let old: dict = v:completed_item", 'E1013: type mismatch, expected dict but got dict') enddef def Test_expr7_special() --- 708,723 ---- assert_equal(g:string_long, "abcdefghijklm") assert_equal(g:string_special, "ab\ncd\ref\ekk") ! call CheckDefFailure(['let x = "abc'], 'E114:') ! call CheckDefFailure(["let x = 'abc"], 'E115:') enddef def Test_expr7_vimvar() let old: list = v:oldfiles let compl: dict = v:completed_item ! call CheckDefFailure(["let old: list = v:oldfiles"], 'E1013: type mismatch, expected list but got list') ! call CheckDefFailure(["let old: dict = v:completed_item"], 'E1013: type mismatch, expected dict but got dict') enddef def Test_expr7_special() *************** *** 755,765 **** assert_equal(g:special_null, v:null) assert_equal(g:special_none, v:none) ! call CheckDefFailure('v:true = true', 'E46:') ! call CheckDefFailure('v:true = false', 'E46:') ! call CheckDefFailure('v:false = true', 'E46:') ! call CheckDefFailure('v:null = 11', 'E46:') ! call CheckDefFailure('v:none = 22', 'E46:') enddef def Test_expr7_list() --- 729,739 ---- assert_equal(g:special_null, v:null) assert_equal(g:special_none, v:none) ! call CheckDefFailure(['v:true = true'], 'E46:') ! call CheckDefFailure(['v:true = false'], 'E46:') ! call CheckDefFailure(['v:false = true'], 'E46:') ! call CheckDefFailure(['v:null = 11'], 'E46:') ! call CheckDefFailure(['v:none = 22'], 'E46:') enddef def Test_expr7_list() *************** *** 770,778 **** assert_equal('b', g:list_mixed[1]) call CheckDefExecFailure("let x = g:anint[3]", 'E714:') ! call CheckDefFailure("let x = g:list_mixed[xxx]", 'E1001:') call CheckDefExecFailure("let x = g:list_mixed['xx']", 'E39:') ! call CheckDefFailure("let x = g:list_mixed[0", 'E111:') call CheckDefExecFailure("let x = g:list_empty[3]", 'E684:') enddef --- 744,752 ---- assert_equal('b', g:list_mixed[1]) call CheckDefExecFailure("let x = g:anint[3]", 'E714:') ! call CheckDefFailure(["let x = g:list_mixed[xxx]"], 'E1001:') call CheckDefExecFailure("let x = g:list_mixed['xx']", 'E39:') ! call CheckDefFailure(["let x = g:list_mixed[0"], 'E111:') call CheckDefExecFailure("let x = g:list_empty[3]", 'E684:') enddef *************** *** 792,807 **** let val = 1 assert_equal(g:dict_one, {key: val}) ! call CheckDefFailure("let x = #{8: 8}", 'E1014:') ! call CheckDefFailure("let x = #{xxx}", 'E720:') ! call CheckDefFailureMult(["let x = #{xxx: 1", "let y = 2"], 'E722:') ! call CheckDefFailure("let x = #{xxx: 1,", 'E723:') ! call CheckDefFailure("let x = {'a': xxx}", 'E1001:') ! call CheckDefFailure("let x = {xxx: 8}", 'E1001:') ! call CheckDefFailure("let x = #{a: 1, a: 2}", 'E721:') ! call CheckDefFailure("let x = #", 'E1015:') ! call CheckDefFailure("let x += 1", 'E1020:') ! call CheckDefFailure("let x = x + 1", 'E1001:') call CheckDefExecFailure("let x = g:anint.member", 'E715:') call CheckDefExecFailure("let x = g:dict_empty.member", 'E716:') enddef --- 766,781 ---- let val = 1 assert_equal(g:dict_one, {key: val}) ! call CheckDefFailure(["let x = #{8: 8}"], 'E1014:') ! call CheckDefFailure(["let x = #{xxx}"], 'E720:') ! call CheckDefFailure(["let x = #{xxx: 1", "let y = 2"], 'E722:') ! call CheckDefFailure(["let x = #{xxx: 1,"], 'E723:') ! call CheckDefFailure(["let x = {'a': xxx}"], 'E1001:') ! call CheckDefFailure(["let x = {xxx: 8}"], 'E1001:') ! call CheckDefFailure(["let x = #{a: 1, a: 2}"], 'E721:') ! call CheckDefFailure(["let x = #"], 'E1015:') ! call CheckDefFailure(["let x += 1"], 'E1020:') ! call CheckDefFailure(["let x = x + 1"], 'E1001:') call CheckDefExecFailure("let x = g:anint.member", 'E715:') call CheckDefExecFailure("let x = g:dict_empty.member", 'E716:') enddef *************** *** 809,815 **** def Test_expr_member() assert_equal(1, g:dict_one.one) ! call CheckDefFailure("let x = g:dict_one.#$!", 'E1002:') enddef def Test_expr7_option() --- 783,789 ---- def Test_expr_member() assert_equal(1, g:dict_one.one) ! call CheckDefFailure(["let x = g:dict_one.#$!"], 'E1002:') enddef def Test_expr7_option() *************** *** 831,837 **** assert_equal('testvar', $TESTVAR) assert_equal('', $ASDF_ASD_XXX) ! call CheckDefFailure("let x = $$$", 'E1002:') enddef def Test_expr7_register() --- 805,811 ---- assert_equal('testvar', $TESTVAR) assert_equal('', $ASDF_ASD_XXX) ! call CheckDefFailure(["let x = $$$"], 'E1002:') enddef def Test_expr7_register() *************** *** 871,877 **** assert_equal('yes', 'yes'->Echo()) assert_equal('yes', 'yes'->s:EchoArg()) ! call CheckDefFailure("let x = 'yes'->Echo", 'E107:') enddef --- 845,851 ---- assert_equal('yes', 'yes'->Echo()) assert_equal('yes', 'yes'->s:EchoArg()) ! call CheckDefFailure(["let x = 'yes'->Echo"], 'E107:') enddef *************** *** 904,942 **** enddef func Test_expr7_fails() ! call CheckDefFailure("let x = (12", "E110:") ! call CheckDefFailure("let x = -'xx'", "E1030:") ! call CheckDefFailure("let x = +'xx'", "E1030:") ! call CheckDefFailure("let x = -0z12", "E974:") call CheckDefExecFailure("let x = -[8]", "E39:") call CheckDefExecFailure("let x = -{'a': 1}", "E39:") ! call CheckDefFailure("let x = @", "E1002:") ! call CheckDefFailure("let x = @<", "E354:") ! call CheckDefFailure("let x = [1, 2", "E697:") ! call CheckDefFailure("let x = [notfound]", "E1001:") ! call CheckDefFailure("let x = { -> 123) }", "E451:") ! call CheckDefFailure("let x = 123->{x -> x + 5) }", "E451:") ! call CheckDefFailure("let x = ¬exist", 'E113:') ! call CheckDefFailure("&grepprg = [343]", 'E1013:') 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:') 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:') --- 878,916 ---- enddef func Test_expr7_fails() ! call CheckDefFailure(["let x = (12"], "E110:") ! call CheckDefFailure(["let x = -'xx'"], "E1030:") ! call CheckDefFailure(["let x = +'xx'"], "E1030:") ! call CheckDefFailure(["let x = -0z12"], "E974:") call CheckDefExecFailure("let x = -[8]", "E39:") call CheckDefExecFailure("let x = -{'a': 1}", "E39:") ! call CheckDefFailure(["let x = @"], "E1002:") ! call CheckDefFailure(["let x = @<"], "E354:") ! call CheckDefFailure(["let x = [1, 2"], "E697:") ! call CheckDefFailure(["let x = [notfound]"], "E1001:") ! call CheckDefFailure(["let x = { -> 123) }"], "E451:") ! call CheckDefFailure(["let x = 123->{x -> x + 5) }"], "E451:") ! call CheckDefFailure(["let x = ¬exist"], 'E113:') ! call CheckDefFailure(["&grepprg = [343]"], 'E1013:') 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:') 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 CheckDefFailure(["let x = ''", "let y = x.memb"], 'E715:') call CheckDefExecFailure("[1, 2->len()", 'E492:') call CheckDefExecFailure("#{a: 1->len()", 'E488:') *************** *** 988,1010 **** func Test_expr7_trailing_fails() ! call CheckDefFailureList(['let l = [2]', 'l->{l -> add(l, 8)}'], 'E107') ! call CheckDefFailureList(['let l = [2]', 'l->{l -> add(l, 8)} ()'], 'E274') endfunc func Test_expr_fails() ! call CheckDefFailure("let x = '1'is2", 'E488:') ! call CheckDefFailure("let x = '1'isnot2", 'E488:') call CheckDefExecFailure("CallMe ('yes')", 'E492:') ! call CheckDefFailure("CallMe2('yes','no')", 'E1069:') ! call CheckDefFailure("CallMe2('yes' , 'no')", 'E1068:') ! call CheckDefFailure("v:nosuch += 3", 'E1001:') ! call CheckDefFailure("let v:statusmsg = ''", '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 --- 962,984 ---- func Test_expr7_trailing_fails() ! call CheckDefFailure(['let l = [2]', 'l->{l -> add(l, 8)}'], 'E107') ! call CheckDefFailure(['let l = [2]', 'l->{l -> add(l, 8)} ()'], 'E274') endfunc func Test_expr_fails() ! call CheckDefFailure(["let x = '1'is2"], 'E488:') ! call CheckDefFailure(["let x = '1'isnot2"], 'E488:') call CheckDefExecFailure("CallMe ('yes')", 'E492:') ! call CheckDefFailure(["CallMe2('yes','no')"], 'E1069:') ! call CheckDefFailure(["CallMe2('yes' , 'no')"], 'E1068:') ! call CheckDefFailure(["v:nosuch += 3"], 'E1001:') ! call CheckDefFailure(["let v:statusmsg = ''"], '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.0639/src/testdir/test_vim9_script.vim 2020-04-23 22:16:49.767270674 +0200 --- src/testdir/test_vim9_script.vim 2020-04-25 18:10:32.892865739 +0200 *************** *** 2,26 **** source check.vim source view_util.vim ! ! " Check that "lines" inside ":def" results in an "error" message. ! func CheckDefFailure(lines, error) ! call writefile(['def Func()'] + a:lines + ['enddef'], 'Xdef') ! call assert_fails('so Xdef', a:error, a:lines) ! call delete('Xdef') ! endfunc ! ! def CheckScriptFailure(lines: list, error: string) ! writefile(lines, 'Xdef') ! assert_fails('so Xdef', error, lines) ! delete('Xdef') ! enddef ! ! def CheckScriptSuccess(lines: list) ! writefile(lines, 'Xdef') ! so Xdef ! delete('Xdef') ! enddef def Test_syntax() let var = 234 --- 2,8 ---- source check.vim source view_util.vim ! source vim9.vim def Test_syntax() let var = 234 *** ../vim-8.2.0639/src/testdir/Make_all.mak 2020-04-13 18:25:05.614342830 +0200 --- src/testdir/Make_all.mak 2020-04-25 18:11:32.912734024 +0200 *************** *** 45,56 **** --- 45,58 ---- # Tests for Vim9 script. TEST_VIM9 = \ + test_vim9_cmd \ test_vim9_disassemble \ test_vim9_expr \ test_vim9_func \ test_vim9_script TEST_VIM9_RES = \ + test_vim9_cmd.res \ test_vim9_disassemble.res \ test_vim9_expr.res \ test_vim9_func.res \ *** ../vim-8.2.0639/src/version.c 2020-04-25 17:13:53.248729906 +0200 --- src/version.c 2020-04-25 19:50:32.006549321 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 640, /**/ -- hundred-and-one symptoms of being an internet addict: 18. Your wife drapes a blond wig over your monitor to remind you of what she looks like. /// 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 ///