Yegappan wrote:
> I see a problem with another example code in vim9.txt:
>
> -----------------------------------------------------------------------
> command -range Rename {
> var save = @a
> @a = 'some expression'
> echo 'do something with ' .. @a
> @a = save
> }
> -----------------------------------------------------------------------
>
> After sourcing the above code, If I invoke the "Rename"
> command more than once, I see the "E1041: Redefining
> script item save" error:
Interestingly, this only happens using a legacy script.
Putting "vim9script" above it avoids the problem.
This must be because in Vim9 script variables are kept local to a block.
In legacy script a variable declared in a block can be used after that
block. On the other hand, the {} block is Vim9 script, thus it's like
the variable is not really defined at the script level.
I think this needs to be fixed, the example should work.
--
You got to work at a mill? Lucky! I got sent back to work in the
acid-mines for my daily crust of stale bread... which not even the
birds would eat.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220321131118.A89C01C783D%40moolenaar.net.