Patch 8.2.4821
Problem:    Crash when imported autoload script was deleted.
Solution:   Initialize local variable. (closes #10274)  Give a more meaningful
            error message.
Files:      src/eval.c, src/vim9script.c, src/testdir/test_vim9_import.vim


*** ../vim-8.2.4820/src/eval.c  2022-04-17 15:06:31.038622659 +0100
--- src/eval.c  2022-04-24 21:13:23.031563955 +0100
***************
*** 6159,6165 ****
            char_u      *exp_name;
            int         cc;
            int         idx;
!           ufunc_T     *ufunc;
            type_T      *type;
  
            // Found script from "import {name} as name", script item name must
--- 6159,6165 ----
            char_u      *exp_name;
            int         cc;
            int         idx;
!           ufunc_T     *ufunc = NULL;
            type_T      *type;
  
            // Found script from "import {name} as name", script item name must
*** ../vim-8.2.4820/src/vim9script.c    2022-04-15 13:53:30.056708670 +0100
--- src/vim9script.c    2022-04-24 21:30:26.846956172 +0100
***************
*** 713,719 ****
--- 713,722 ----
      if (script->sn_import_autoload && script->sn_state == SN_STATE_NOT_LOADED)
      {
        if (do_source(script->sn_name, FALSE, DOSO_NONE, NULL) == FAIL)
+       {
+           semsg(_(e_cant_open_file_str), script->sn_name);
            return -1;
+       }
      }
  
      // Find name in "script".
*** ../vim-8.2.4820/src/testdir/test_vim9_import.vim    2022-04-23 
10:50:18.971609285 +0100
--- src/testdir/test_vim9_import.vim    2022-04-24 21:30:01.878973257 +0100
***************
*** 1137,1142 ****
--- 1137,1161 ----
    delete('autoload', 'rf')
  enddef
  
+ def Test_autoload_import_deleted()
+   var lines =<< trim END
+       vim9script
+       export const FOO = 1
+   END
+   writefile(lines, 'Xa.vim')
+ 
+   lines =<< trim END
+       vim9script
+       import autoload './Xa.vim'
+ 
+       delete('Xa.vim')
+       var x = Xa.FOO
+   END
+   v9.CheckScriptFailure(lines, 'E484:')
+ 
+   delete('Xdir', 'rf')
+ enddef
+ 
  func Test_import_in_diffexpr()
    CheckExecutable diff
  
*** ../vim-8.2.4820/src/version.c       2022-04-24 18:40:20.791116268 +0100
--- src/version.c       2022-04-24 21:15:05.943465276 +0100
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4821,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
44. Your friends no longer send you e-mail...they just log on to your IRC
    channel.

 /// 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/20220424203430.A46DA1C43E2%40moolenaar.net.

Raspunde prin e-mail lui