To: vim_dev@googlegroups.com Subject: Patch 8.2.1323 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1323 Problem: Vim9: invalid operators only rejected in :def function. Solution: Also reject them at script level. (closes #6564) Files: src/eval.c, src/vim9compile.c, src/proto/vim9compile.pro, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1322/src/eval.c 2020-07-27 21:43:24.137946109 +0200 --- src/eval.c 2020-07-29 20:48:35.100584948 +0200 *************** *** 2420,2428 **** { char_u *p; int getnext; - int i; exptype_T type = EXPR_UNKNOWN; int len = 2; /* * Get the first variable. --- 2420,2428 ---- { char_u *p; int getnext; exptype_T type = EXPR_UNKNOWN; int len = 2; + int type_is = FALSE; /* * Get the first variable. *************** *** 2431,2474 **** return FAIL; p = eval_next_non_blank(*arg, evalarg, &getnext); ! switch (p[0]) ! { ! case '=': if (p[1] == '=') ! type = EXPR_EQUAL; ! else if (p[1] == '~') ! type = EXPR_MATCH; ! break; ! case '!': if (p[1] == '=') ! type = EXPR_NEQUAL; ! else if (p[1] == '~') ! type = EXPR_NOMATCH; ! break; ! case '>': if (p[1] != '=') ! { ! type = EXPR_GREATER; ! len = 1; ! } ! else ! type = EXPR_GEQUAL; ! break; ! case '<': if (p[1] != '=') ! { ! type = EXPR_SMALLER; ! len = 1; ! } ! else ! type = EXPR_SEQUAL; ! break; ! case 'i': if (p[1] == 's') ! { ! if (p[2] == 'n' && p[3] == 'o' && p[4] == 't') ! len = 5; ! i = p[len]; ! if (!isalnum(i) && i != '_') ! type = len == 2 ? EXPR_IS : EXPR_ISNOT; ! } ! break; ! } /* * If there is a comparative operator, use it. --- 2431,2437 ---- return FAIL; p = eval_next_non_blank(*arg, evalarg, &getnext); ! type = get_compare_type(p, &len, &type_is); /* * If there is a comparative operator, use it. *************** *** 2482,2487 **** --- 2445,2457 ---- if (getnext) *arg = eval_next_line(evalarg); + if (vim9script && type_is && (p[len] == '?' || p[len] == '#')) + { + semsg(_(e_invexpr2), p); + clear_tv(rettv); + return FAIL; + } + // extra question mark appended: ignore case if (p[len] == '?') { *** ../vim-8.2.1322/src/vim9compile.c 2020-07-29 19:17:57.328394592 +0200 --- src/vim9compile.c 2020-07-29 20:45:09.661632877 +0200 *************** *** 3633,3639 **** } } ! static exptype_T get_compare_type(char_u *p, int *len, int *type_is) { exptype_T type = EXPR_UNKNOWN; --- 3633,3639 ---- } } ! exptype_T get_compare_type(char_u *p, int *len, int *type_is) { exptype_T type = EXPR_UNKNOWN; *** ../vim-8.2.1322/src/proto/vim9compile.pro 2020-07-26 17:56:20.448638742 +0200 --- src/proto/vim9compile.pro 2020-07-29 20:47:49.320818121 +0200 *************** *** 16,21 **** --- 16,22 ---- char_u *peek_next_line_from_context(cctx_T *cctx); char_u *next_line_from_context(cctx_T *cctx, int skip_comment); char_u *to_name_const_end(char_u *arg); + exptype_T get_compare_type(char_u *p, int *len, int *type_is); int assignment_len(char_u *p, int *heredoc); void vim9_declare_error(char_u *name); int check_vim9_unlet(char_u *name); *** ../vim-8.2.1322/src/testdir/test_vim9_expr.vim 2020-07-29 20:00:35.123334575 +0200 --- src/testdir/test_vim9_expr.vim 2020-07-29 20:49:05.052432474 +0200 *************** *** 831,837 **** enddef def Test_expr5_vim9script() ! # only checks line continuation let lines =<< trim END vim9script let var = 11 --- 831,837 ---- enddef def Test_expr5_vim9script() ! # check line continuation let lines =<< trim END vim9script let var = 11 *************** *** 848,853 **** --- 848,877 ---- assert_equal('onetwo', var) END CheckScriptSuccess(lines) + + lines =<< trim END + vim9script + echo 'abc' is# 'abc' + END + CheckScriptFailure(lines, 'E15:') + + lines =<< trim END + vim9script + echo 'abc' is? 'abc' + END + CheckScriptFailure(lines, 'E15:') + + lines =<< trim END + vim9script + echo 'abc' isnot# 'abc' + END + CheckScriptFailure(lines, 'E15:') + + lines =<< trim END + vim9script + echo 'abc' isnot? 'abc' + END + CheckScriptFailure(lines, 'E15:') enddef def Test_expr5_float() *** ../vim-8.2.1322/src/version.c 2020-07-29 20:00:35.123334575 +0200 --- src/version.c 2020-07-29 20:39:59.503225043 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1323, /**/ -- Momento mori, ergo carpe diem /// 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 ///