Yegappan wrote:

> > > The following sample code throws E1013 error in line 10 with Vim9:
> > >
> > > ============================================
> > > vim9script
> > >
> > > def Test()
> > >   var notif: dict<any> = {}
> > >   var docID: dict<any> = {}
> > >   var changeSet: list<dict<any>>
> > >
> > >   docID.uri = 'buf'
> > >   changeSet->add({text: ['one']})
> > >
> > >   notif.params = {}
> > >   notif.params->extend({textDocument: docID})
> > >   notif.params->extend({content: changeSet})
> > > enddef
> > >
> > > call Test()
> > > ============================================
> > >
> > > This used to work till recently.
> >
> > The error is:
> > 1013: Argument 2: type mismatch, expected dict<dict<string>> but got 
> > dict<list<
> > dict<list<string>>>>
> >
> > extend() is now checking that the dictionary does not change type.
> >
> 
> The 'notif' variable is declared to be of type "dict<any>". So I thought
> we could add elements of different types to this dict. But it looks like
> the type of the first element that is added to the dict is used to check
> the types of additional elements that are added later. I didn't expect
> that.

If you add a dict to the "notif" dict, that dict also has a type that is
being checked.  The "any" does not work for members inside "notif".

The problem is that if extend() is used for a declared type then we must
check it matches that type, but when the type wasn't declared we do not
need to do that, but there is no clue this is the case.  There might be
a better way to do this somehow.

-- 
GUARD #2:  Wait a minute -- supposing two swallows carried it together?
GUARD #1:  No, they'd have to have it on a line.
GUARD #2:  Well, simple!  They'd just use a standard creeper!
GUARD #1:  What, held under the dorsal guiding feathers?
GUARD #2:  Well, why not?
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            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/202102080907.11897hHa3058766%40masaka.moolenaar.net.

Raspunde prin e-mail lui