patch 9.1.0338: Vim9: import through symlinks not correctly handled
Problem: Vim9: import through symlinks not correctly handled
Solution: Check for script being a symlink but only once
(Ernie Rael)
closes: #14565
Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index 67b6759..156b035 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -2930,6 +2930,33 @@
unlet g:resultValue
&rtp = save_rtp
delete('Xfrom', 'rf')
+
+ # Access item from :def imported through symbolic linked directory. #14536
+ mkdir('Xto/real_dir', 'pR')
+ lines =<< trim END
+ vim9script
+ export const val = 17
+ export def F(): number
+ return 23
+ enddef
+ END
+ writefile(lines, 'Xto/real_dir/real_file.vim')
+ system('ln -s real_dir Xto/syml_dir')
+ defer delete('Xto/syml_dir')
+ lines =<< trim END
+ vim9script
+ import autoload './Xto/syml_dir/real_file.vim'
+
+ def Fmain()
+ assert_equal(17, real_file.val)
+ enddef
+ def F2()
+ assert_equal(23, real_file.F())
+ enddef
+ Fmain()
+ F2()
+ END
+ v9.CheckScriptSuccess(lines)
endif
enddef