Patch 8.2.4067
Problem:    Vim9: cannot call imported function with :call. (Drew Vogel)
Solution:   Translate the function name. (closes #9510)
Files:      src/userfunc.c, src/testdir/test_vim9_import.vim


*** ../vim-8.2.4066/src/userfunc.c      2022-01-11 15:24:01.307663435 +0000
--- src/userfunc.c      2022-01-12 12:34:27.125251889 +0000
***************
*** 3744,3749 ****
--- 3744,3773 ----
        if (name == lv.ll_exp_name)
            name = NULL;
      }
+     else if (lv.ll_sid > 0)
+     {
+       scriptitem_T    *si = SCRIPT_ITEM(lv.ll_sid);
+       int             cc = *lv.ll_name_end;
+ 
+       // function in another script.  Prefix <SNR>99_ or the autoload prefix.
+       *lv.ll_name_end = NUL;
+       if (si->sn_autoload_prefix != NULL)
+       {
+           name = concat_str(si->sn_autoload_prefix, lv.ll_name);
+       }
+       else
+       {
+           sid_buf[0] = K_SPECIAL;
+           sid_buf[1] = KS_EXTRA;
+           sid_buf[2] = (int)KE_SNR;
+           vim_snprintf((char *)sid_buf + 3, sizeof(sid_buf) - 3,
+                                           "%ld_", (long)current_sctx.sc_sid);
+           name = concat_str(sid_buf, lv.ll_name);
+       }
+       *lv.ll_name_end = cc;
+       *pp = end;
+       goto theend;
+     }
      else if (!(flags & TFN_NO_DEREF))
      {
        len = (int)(end - *pp);
*** ../vim-8.2.4066/src/testdir/test_vim9_import.vim    2022-01-12 
11:46:36.314615880 +0000
--- src/testdir/test_vim9_import.vim    2022-01-12 12:44:30.894975406 +0000
***************
*** 1185,1190 ****
--- 1185,1219 ----
    END
    CheckScriptSuccess(lines)
  
+   unlet g:prefixed_loaded
+   unlet g:expected_loaded
+   delete('Xdir', 'rf')
+   &rtp = save_rtp
+ enddef
+ 
+ def Test_vim9script_autoload_call()
+   mkdir('Xdir/autoload', 'p')
+   var save_rtp = &rtp
+   exe 'set rtp^=' .. getcwd() .. '/Xdir'
+ 
+   var lines =<< trim END
+      vim9script autoload
+ 
+      export def Getother()
+        g:result = 'other'
+      enddef
+   END
+   writefile(lines, 'Xdir/autoload/other.vim')
+ 
+   lines =<< trim END
+       vim9script
+       import autoload 'other.vim'
+       call other.Getother()
+       assert_equal('other', g:result)
+   END
+   CheckScriptSuccess(lines)
+ 
+   unlet g:result
    delete('Xdir', 'rf')
    &rtp = save_rtp
  enddef
*** ../vim-8.2.4066/src/version.c       2022-01-12 11:46:36.314615880 +0000
--- src/version.c       2022-01-12 12:27:37.434868123 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4067,
  /**/

-- 
       When danger reared its ugly head,
       He bravely turned his tail and fled
       Yes, Brave Sir Robin turned about
       And gallantly he chickened out
       Bravely taking to his feet
       He beat a very brave retreat
       Bravest of the brave Sir Robin
       Petrified of being dead
       Soiled his pants then brave Sir Robin
       Turned away and fled.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/20220112124925.0830C1C05F1%40moolenaar.net.

Raspunde prin e-mail lui