Yegappan wrote:

> When I source the following example code fragment in vim9.txt
> (under vim9-no-dict-function), I get the "E1168: Argument already
> declared in the script: d" error.
> 
> -----------------------------------------------------------------
>         def DictFunc(d: dict<any>, arg: string)
>            echo d[arg]
>         enddef
>         var d = {item: 'value', func: DictFunc}
>         d.func(d, 'item')
> -----------------------------------------------------------------
> 
> Either the example should be changed or the code should be modified
> to support this usage.
> 
> I was testing the ":source" command to source vim9 code when I ran
> into this problem.

Ah, we added a rule that an argument cannot shadow a script variable.
I'll change the name of the script variable.

I don't think we should change this rule for shadowing, when using "d"
in the function it might not be clear if the user intended to use the
argument or the script variable.  Especially if the function gets long
and the types match.

It's actually nice that the new :source functionality makes this easy to
try out.  However, it might be that two examples overlap, since this
file is a help file with unrelated examples.  Perhaps we need a way to
clear what the script contains?  We can't use "!", it already has a
meaning for :source.  Perhaps "[range]source ++clear" ?

-- 
Yah, well, we had to carve our electrons out of driftwood we'd
find.  In the winter.  Uphill.  Both ways.

 /// 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/20220321111112.56B001C783D%40moolenaar.net.

Raspunde prin e-mail lui