Create ~/vimfiles/autoload/x.vim with the following content:
vim9script
export enum Fruit
Banana,
Apple
endenum
If you source it twice, then you get E1041.
If you move away the script from autoload folders, then you can source it as many way as you want.
It should be possible to source the script as many times as user want without throwing any error.
9.1-1942
Win 11
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
This seems working as expected.
Files under autoload/ update the loaded information for the file path name (x in this case) the first time they are loaded.
The first time :so is used, the loaded information for the file path name (x) is internally updated to indicate that it has been loaded, but the second time :so is used, the file has already been loaded, resulting in an E1041 error.
Normally, Vim9 scripts use import autoload for the autoload mechanism.
This allows control that loads only the first time to work correctly.
vim9script import autoload 'x.vim' var f = x#Fruit.Banana echo $"f: {f.name}"
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@yegappan What is your take on this?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
So what is the point of having noclear and why moving scripts in another folder won't suffer the same problem. The current behavior is cumbersome in vim9 context.
I could understand such a behavior in legacy-vim (and for every script), but definitely not in Vin9.
In vim9 you have noclear if you really want such a behavior.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Normal def functions can be redefined, but since enum/class are part of the type system, I believe redefining them is prohibited due to compatibility issues with existing instances.
I think you should either use import autoload, or define export enum and export class outside of autoload/.
If you are developing a plugin and have made changes to autoload/x.vim, restart Vim.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()