To: vim_dev@googlegroups.com Subject: Patch 8.2.2396 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.2396 Problem: Vim9: no white space allowed before "->". Solution: Allow for white space. (closes #7725) Files: src/ex_docmd.c, src/eval.c, src/testdir/test_vim9_cmd.vim *** ../vim-8.2.2395/src/ex_docmd.c 2021-01-16 20:20:59.646487092 +0100 --- src/ex_docmd.c 2021-01-23 13:59:24.252656985 +0100 *************** *** 3313,3320 **** if (vim_strchr((char_u *)"{('[\"@", *p) != NULL || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) { ! int oplen; ! int heredoc; if ( // "(..." is an expression. --- 3313,3321 ---- if (vim_strchr((char_u *)"{('[\"@", *p) != NULL || ((p = to_name_const_end(pskip)) > eap->cmd && *p != NUL)) { ! int oplen; ! int heredoc; ! char_u *swp = skipwhite(p); if ( // "(..." is an expression. *************** *** 3332,3338 **** || eap->cmd[1] == ':' ) // "varname->func()" is an expression. ! : (*p == '-' && p[1] == '>'))) { if (*eap->cmd == '{' && ends_excmd(*skipwhite(eap->cmd + 1))) { --- 3333,3339 ---- || eap->cmd[1] == ':' ) // "varname->func()" is an expression. ! : (*swp == '-' && swp[1] == '>'))) { if (*eap->cmd == '{' && ends_excmd(*skipwhite(eap->cmd + 1))) { *** ../vim-8.2.2395/src/eval.c 2021-01-21 12:34:11.437508292 +0100 --- src/eval.c 2021-01-23 14:20:15.744968442 +0100 *************** *** 3671,3677 **** /* * Evaluate "->method()". ! * "*arg" points to the '-'. * Returns FAIL or OK. "*arg" is advanced to after the ')'. */ static int --- 3671,3677 ---- /* * Evaluate "->method()". ! * "*arg" points to "method". * Returns FAIL or OK. "*arg" is advanced to after the ')'. */ static int *************** *** 3686,3693 **** typval_T base = *rettv; int ret; - // Skip over the ->. - *arg += 2; rettv->v_type = VAR_UNKNOWN; if (**arg == '{') --- 3686,3691 ---- *************** *** 3735,3741 **** /* * Evaluate "->method()". ! * "*arg" points to the '-'. * Returns FAIL or OK. "*arg" is advanced to after the ')'. */ static int --- 3733,3739 ---- /* * Evaluate "->method()". ! * "*arg" points to "method". * Returns FAIL or OK. "*arg" is advanced to after the ')'. */ static int *************** *** 3753,3760 **** int evaluate = evalarg != NULL && (evalarg->eval_flags & EVAL_EVALUATE); - // Skip over the ->. - *arg += 2; rettv->v_type = VAR_UNKNOWN; name = *arg; --- 3751,3756 ---- *************** *** 5765,5774 **** } else if (p[0] == '-' && p[1] == '>') { ! *arg = p; if (ret == OK) { ! if (((*arg)[2] == '{' && !in_vim9script()) || (*arg)[2] == '(') // expr->{lambda}() or expr->(lambda)() ret = eval_lambda(arg, rettv, evalarg, verbose); else --- 5761,5770 ---- } else if (p[0] == '-' && p[1] == '>') { ! *arg = skipwhite(p + 2); if (ret == OK) { ! if ((**arg == '{' && !in_vim9script()) || **arg == '(') // expr->{lambda}() or expr->(lambda)() ret = eval_lambda(arg, rettv, evalarg, verbose); else *** ../vim-8.2.2395/src/testdir/test_vim9_cmd.vim 2021-01-19 22:48:06.267990184 +0100 --- src/testdir/test_vim9_cmd.vim 2021-01-23 14:13:07.274122686 +0100 *************** *** 319,324 **** --- 319,338 ---- CheckScriptSuccess(lines) enddef + def Test_method_call_whitespace() + var lines =<< trim END + new + var yank = 'text' + yank->setline(1) + yank ->setline(2) + yank-> setline(3) + yank -> setline(4) + assert_equal(['text', 'text', 'text', 'text'], getline(1, 4)) + bwipe! + END + CheckDefAndScriptSuccess(lines) + enddef + def Test_skipped_expr_linebreak() if 0 var x = [] *** ../vim-8.2.2395/src/version.c 2021-01-23 13:39:10.395533599 +0100 --- src/version.c 2021-01-23 14:06:30.087263331 +0100 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 2396, /**/ -- 'Psychologist' -- Someone who looks at everyone else when an attractive woman enters the room. /// 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 ///