Vim9: Unexpected Argument name shadows existing variable error

13 views
Skip to first unread message

Yegappan Lakshmanan

unread,
Mar 16, 2022, 11:43:19 AM3/16/22
to vim_dev
Hi,

With the recent changes to Vim9, I started seeing the
"E1167: Argument name shadows existing variable" error with the LSP plugin.

I am able to reproduce this error with the below sample script:

--------------------------------------------------------------------------------------------
vim9script

def ProcessInitializeReply(lspserver: dict<any>)
enddef

def ProcessReply(lspserver: dict<any>)
var lsp_reply_handlers: dict<func> =
{
'initialize': ProcessInitializeReply
}
lsp_reply_handlers['initialize']()
enddef

call ProcessReply({})
--------------------------------------------------------------------------------------------

If you source the above script with the latest Vim, you will see the
E1167 error.

I don't see any problems with this usage. The arguments to the ProcessReply()
and ProcessInititializeReply() functions are named "lspserver". But these
are two separate functions. So I should be able to use the same name for
the arguments.

- Yegappan

Yegappan Lakshmanan

unread,
Mar 16, 2022, 11:45:28 AM3/16/22
to vim_dev
Hi,

On Wed, Mar 16, 2022 at 8:43 AM Yegappan Lakshmanan <yega...@gmail.com> wrote:
>
> Hi,
>
> With the recent changes to Vim9, I started seeing the
> "E1167: Argument name shadows existing variable" error with the LSP plugin.
>
> I am able to reproduce this error with the below sample script:
>

A minor update to the sample script is below:

--------------------------------------------------------------------------------------------
vim9script

def ProcessInitializeReply(lspserver: dict<any>)
enddef

def ProcessReply(lspserver: dict<any>)
var lsp_reply_handlers: dict<func> =
{
'initialize': ProcessInitializeReply
}
lsp_reply_handlers['initialize'](lspserver)

Yegappan Lakshmanan

unread,
Mar 16, 2022, 12:21:02 PM3/16/22
to vim_dev
Jo.

On Wed, Mar 16, 2022 at 8:45 AM Yegappan Lakshmanan <yega...@gmail.com> wrote:
> >
> > With the recent changes to Vim9, I started seeing the
> > "E1167: Argument name shadows existing variable" error with the LSP plugin.
>

This problem is caused by the changes made for "8.2.4575: Vim9: test
for profiling still fails".

- Yegappan

Bram Moolenaar

unread,
Mar 16, 2022, 1:47:00 PM3/16/22
to vim...@googlegroups.com, Yegappan Lakshmanan

Yegappan wrote:

> > >
> > > I am able to reproduce this error with the below sample script:
> > >
> >
> > A minor update to the sample script is below:
> >
> > --------------------------------------------------------------------------------------------
> > vim9script
> >
> > def ProcessInitializeReply(lspserver: dict<any>)
> > enddef
> >
> > def ProcessReply(lspserver: dict<any>)
> > var lsp_reply_handlers: dict<func> =
> > {
> > 'initialize': ProcessInitializeReply
> > }
> > lsp_reply_handlers['initialize'](lspserver)
> > enddef
> >
> > call ProcessReply({})
> > --------------------------------------------------------------------------------------------
> On Wed, Mar 16, 2022 at 8:45 AM Yegappan Lakshmanan <yega...@gmail.com> wrote:
> > >
> > > With the recent changes to Vim9, I started seeing the
> > > "E1167: Argument name shadows existing variable" error with the LSP plugin.
> >
>
> This problem is caused by the changes made for "8.2.4575: Vim9: test
> for profiling still fails".

OK, with this example I can reproduce it. I suspect it's because "cctx"
is being passed when compiling ProcessInitializeReply()... Yes.
If I revert that no test fails, thus it might be OK.

--
A cow comes flying over the battlements, lowing aggressively. The cow
lands on GALAHAD'S PAGE, squashing him completely.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages