patch 9.1.0165: Vim9: Importing an autoload imported script fails

Commit: 
https://github.com/vim/vim/commit/fa6300872732f80b770a768e785ae2b189d3e684
Author: Yegappan Lakshmanan <yegap...@yahoo.com>
Date:   Sun Mar 10 19:22:38 2024 +0100

    patch 9.1.0165: Vim9: Importing an autoload imported script fails
    
    Problem:  Vim9: Importing an autoload imported script fails
              (Song-Tianxiang)
    Solution: Return the script ID in this case
              (Yegappan Lakshmanan)
    
    fixes: #14171
    closes: #14174
    
    Signed-off-by: Yegappan Lakshmanan <yegap...@yahoo.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/scriptfile.c b/src/scriptfile.c
index 69016bfb1..6dc55579a 100644
--- a/src/scriptfile.c
+++ b/src/scriptfile.c
@@ -1690,6 +1690,8 @@ do_source_ext(
            // reset version, "vim9script" may have been added or removed.
            si->sn_version = 1;
        }
+       if (ret_sid != NULL)
+           *ret_sid = sid;
     }
     else
     {
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index d470a3467..fa1aeb10e 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -2929,5 +2929,54 @@ def Test_export_in_conditional_block()
   v9.CheckScriptSuccess(lines)
 enddef
 
+" Import fails when an autoloaded script is imported again.
+" Github issue #14171
+def Test_import_autloaded_script()
+  mkdir('Ximporttwice', 'pR')
+  mkdir('Ximporttwice/plugin')
+  mkdir('Ximporttwice/autoload')
+  var save_rtp = &rtp
+  exe 'set rtp^=' .. getcwd() .. '/Ximporttwice'
+
+  var lines =<< trim END
+    vim9script
+
+    export def H(): number
+      return 10
+    enddef
+  END
+  writefile(lines, 'Ximporttwice/autoload/hello.vim')
+
+  lines =<< trim END
+    vim9script
+
+    import "./hello.vim"
+    export def W(): number
+      return 20
+    enddef
+  END
+  writefile(lines, 'Ximporttwice/autoload/world.vim')
+
+  lines =<< trim END
+    vim9script
+
+    import autoload '../autoload/hello.vim'
+    import autoload '../autoload/world.vim'
+
+    command Hello echo hello.H()
+    command World echo world.W()
+  END
+  writefile(lines, 'Ximporttwice/plugin/main.vim')
+
+  lines =<< trim END
+    vim9script
+
+    source ./Ximporttwice/plugin/main.vim
+    assert_equal(['20'], execute('World')->split("
"))
+  END
+  v9.CheckScriptSuccess(lines)
+
+  &rtp = save_rtp
+enddef
 
 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/version.c b/src/version.c
index b46b35586..e1b13bdd4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    165,
 /**/
     164,
 /**/

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rjNvv-00BLKI-LQ%40256bit.org.

Raspunde prin e-mail lui