diff src/vim9compile.c @ 21699:1b96535705a0 v8.2.1399

patch 8.2.1399: Vim9: may find imported item in wrong script Commit: https://github.com/vim/vim/commit/efa94447e85eacce62c1fcf6b63e7f3431e2cb1b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 8 22:16:00 2020 +0200 patch 8.2.1399: Vim9: may find imported item in wrong script Problem: Vim9: may find imported item in wrong script. Solution: When looking up script-local function use the embedded script ID. (issue #6644)
author Bram Moolenaar <Bram@vim.org>
date Sat, 08 Aug 2020 22:30:03 +0200
parents 4e4fd845553d
children d2dee69de7c7
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2548,12 +2548,10 @@ get_script_item_idx(int sid, char_u *nam
     imported_T *
 find_imported(char_u *name, size_t len, cctx_T *cctx)
 {
-    scriptitem_T    *si;
     int		    idx;
 
     if (current_sctx.sc_sid <= 0)
 	return NULL;
-    si = SCRIPT_ITEM(current_sctx.sc_sid);
     if (cctx != NULL)
 	for (idx = 0; idx < cctx->ctx_imports.ga_len; ++idx)
 	{
@@ -2566,6 +2564,15 @@ find_imported(char_u *name, size_t len, 
 		return import;
 	}
 
+    return find_imported_in_script(name, len, current_sctx.sc_sid);
+}
+
+    imported_T *
+find_imported_in_script(char_u *name, size_t len, int sid)
+{
+    scriptitem_T    *si = SCRIPT_ITEM(sid);
+    int		    idx;
+
     for (idx = 0; idx < si->sn_imports.ga_len; ++idx)
     {
 	imported_T *import = ((imported_T *)si->sn_imports.ga_data) + idx;