Patch 9.0.1081
Problem:    Using "->" with split lines does not always work.
Solution:   Avoid trying to get another line. (closes #11723)
Files:      src/eval.c, src/testdir/test_user_func.vim


*** ../vim-9.0.1080/src/eval.c  2022-12-18 21:42:49.010716927 +0000
--- src/eval.c  2022-12-19 20:26:08.073476338 +0000
***************
*** 4548,4558 ****
        if (**arg != '(' && alias == NULL
                                    && (paren = vim_strchr(*arg, '(')) != NULL)
        {
-           char_u *deref;
- 
            *arg = name;
            *paren = NUL;
!           deref = deref_function_name(arg, &tofree, evalarg, verbose);
            if (deref == NULL)
            {
                *arg = name + len;
--- 4548,4566 ----
        if (**arg != '(' && alias == NULL
                                    && (paren = vim_strchr(*arg, '(')) != NULL)
        {
            *arg = name;
+ 
+           // Truncate the name a the "(".  Avoid trying to get another line
+           // by making "getline" NULL.
            *paren = NUL;
!           char_u      *(*getline)(int, void *, int, getline_opt_T) = NULL;
!           if (evalarg != NULL)
!           {
!               getline = evalarg->eval_getline;
!               evalarg->eval_getline = NULL;
!           }
! 
!           char_u *deref = deref_function_name(arg, &tofree, evalarg, verbose);
            if (deref == NULL)
            {
                *arg = name + len;
***************
*** 4563,4569 ****
--- 4571,4580 ----
                name = deref;
                len = (long)STRLEN(name);
            }
+ 
            *paren = '(';
+           if (getline != NULL)
+               evalarg->eval_getline = getline;
        }
  
        if (ret == OK)
*** ../vim-9.0.1080/src/testdir/test_user_func.vim      2022-10-15 
21:35:51.191403811 +0100
--- src/testdir/test_user_func.vim      2022-12-19 20:25:13.369634729 +0000
***************
*** 179,184 ****
--- 179,238 ----
    eval 'bar'->s:addFoo()->assert_equal('barfoo')
  endfunc
  
+ func Test_method_with_linebreaks()
+   let lines =<< trim END
+       vim9script
+ 
+       export def Scan(ll: list<number>): func(func(number))
+         return (Emit: func(number)) => {
+           for v in ll
+             Emit(v)
+           endfor
+         }
+       enddef
+ 
+       export def Build(Cont: func(func(number))): list<number>
+         var result: list<number> = []
+         Cont((v) => {
+             add(result, v)
+         })
+         return result
+       enddef
+ 
+       export def Noop(Cont: func(func(number))): func(func(number))
+         return (Emit: func(number)) => {
+           Cont(Emit)
+         }
+       enddef
+   END
+   call writefile(lines, 'Xlib.vim', 'D')
+ 
+   let lines =<< trim END
+       vim9script
+ 
+       import "./Xlib.vim" as lib
+ 
+       const x = [1, 2, 3]
+ 
+       var result = lib.Scan(x)->lib.Noop()->lib.Build()
+       assert_equal([1, 2, 3], result)
+ 
+       result = lib.Scan(x)->lib.Noop()
+               ->lib.Build()
+       assert_equal([1, 2, 3], result)
+ 
+       result = lib.Scan(x)
+             ->lib.Noop()->lib.Build()
+       assert_equal([1, 2, 3], result)
+ 
+       result = lib.Scan(x)
+                 ->lib.Noop()
+                 ->lib.Build()
+       assert_equal([1, 2, 3], result)
+   END
+   call v9.CheckScriptSuccess(lines)
+ endfunc
+ 
  func Test_failed_call_in_try()
    try | call UnknownFunc() | catch | endtry
  endfunc
*** ../vim-9.0.1080/src/version.c       2022-12-19 18:56:44.173594364 +0000
--- src/version.c       2022-12-19 20:26:23.833433379 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1081,
  /**/

-- 
The question is:  What do you do with your life?
The wrong answer is: Become the richest guy in the graveyard.
                                (billionaire and Oracle founder Larry Ellison)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20221219202913.142481C09DC%40moolenaar.net.

Raspunde prin e-mail lui