Skip to content

Vim9: E1041 when reloading an autoload script with exported variables#20726

Open
h-east wants to merge 1 commit into
vim:masterfrom
h-east:fix-autoload-export-var-reload
Open

Vim9: E1041 when reloading an autoload script with exported variables#20726
h-east wants to merge 1 commit into
vim:masterfrom
h-east:fix-autoload-export-var-reload

Conversation

@h-east

@h-east h-east commented Jul 6, 2026

Copy link
Copy Markdown
Member
Problem:  Sourcing a Vim9 autoload script more than once fails with E1041
          for its exported variables and constants, while exported functions
          reload without error.
Solution: Give exported variables and constants the same clean slate as
          functions on reload by removing them from the global namespace, so
          the script body can define them again.  Keep classes and enums:
          objects created from the previous definition still refer to it, so
          they are not redefined this way.

fixes: #19205

Problem:  Sourcing a Vim9 autoload script more than once fails with E1041
          for its exported variables and constants, while exported functions
          reload without error.
Solution: Give exported variables and constants the same clean slate as
          functions on reload by removing them from the global namespace, so
          the script body can define them again.  Keep classes and enums:
          objects created from the previous definition still refer to it, so
          they are not redefined this way.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

E1041 is thrown when a variable is exported from a script contained in the autoload/ folder and the script is sourced more than once

1 participant