Patch 8.2.4330
Problem:    Vim9: no error if script imports itself.
Solution:   Give an error when a script imports itself.
Files:      src/vim9script.c, src/errors.h, src/testdir/test_vim9_import.vim


*** ../vim-8.2.4329/src/vim9script.c    2022-01-26 16:45:16.934506694 +0000
--- src/vim9script.c    2022-02-08 19:03:01.684175693 +0000
***************
*** 516,521 ****
--- 516,527 ----
        goto erret;
      }
  
+     if (sid == current_sctx.sc_sid)
+     {
+       emsg(_(e_script_cannot_import_itself));
+       goto erret;
+     }
+ 
      import_gap = gap != NULL ? gap : &SCRIPT_ITEM(import_sid)->sn_imports;
      for (i = 0; i < import_gap->ga_len; ++i)
      {
*** ../vim-8.2.4329/src/errors.h        2022-02-07 21:53:58.085529486 +0000
--- src/errors.h        2022-02-08 19:02:40.700136333 +0000
***************
*** 2802,2808 ****
        INIT(= N_("E1086: Function reference invalid"));
  EXTERN char e_cannot_use_index_when_declaring_variable[]
        INIT(= N_("E1087: Cannot use an index when declaring a variable"));
! // E1088 unused
  EXTERN char e_unknown_variable_str[]
        INIT(= N_("E1089: Unknown variable: %s"));
  EXTERN char e_cannot_assign_to_argument[]
--- 2802,2809 ----
        INIT(= N_("E1086: Function reference invalid"));
  EXTERN char e_cannot_use_index_when_declaring_variable[]
        INIT(= N_("E1087: Cannot use an index when declaring a variable"));
! EXTERN char e_script_cannot_import_itself[]
!       INIT(= N_("E1088: Script cannot import itself"));
  EXTERN char e_unknown_variable_str[]
        INIT(= N_("E1089: Unknown variable: %s"));
  EXTERN char e_cannot_assign_to_argument[]
*** ../vim-8.2.4329/src/testdir/test_vim9_import.vim    2022-02-06 
13:08:37.467920903 +0000
--- src/testdir/test_vim9_import.vim    2022-02-08 19:10:18.116578563 +0000
***************
*** 500,506 ****
    v9.CheckScriptFailure(lines, 'E1262:')
  
    delete('Xthat.vim')
!  
    mkdir('Ximport')
  
    writefile(['vim9script'], 'Ximport/.vim')
--- 500,515 ----
    v9.CheckScriptFailure(lines, 'E1262:')
  
    delete('Xthat.vim')
! 
!   lines =<< trim END
!       vim9script
!       export var item = 'hello'
!       import './Xyourself.vim'
!   END
!   writefile(lines, 'Xyourself.vim')
!   assert_fails('source Xyourself.vim', 'E1088:')
!   delete('Xyourself.vim')
! 
    mkdir('Ximport')
  
    writefile(['vim9script'], 'Ximport/.vim')
*** ../vim-8.2.4329/src/version.c       2022-02-08 18:08:49.940360054 +0000
--- src/version.c       2022-02-08 19:04:19.360301691 +0000
***************
*** 748,749 ****
--- 748,751 ----
  {   /* Add new patch number below this line */
+ /**/
+     4330,
  /**/

-- 
How To Keep A Healthy Level Of Insanity:
1. At lunch time, sit in your parked car with sunglasses on and point
   a hair dryer at passing cars. See if they slow down.

 /// 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/20220208191346.40C211C1905%40moolenaar.net.

Raspunde prin e-mail lui