Hi Bram,
On Sun, Feb 7, 2021 at 11:43 AM Bram Moolenaar <[email protected]> wrote:
>
>
> 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.
Regards,
Yegappan
> In this case the dict members are of mixed type. Not sure if we should
> somehow not check the type. You can use extendnew() at least.
> Or use one extend() instead of two:
>
> notif.params = {}
> notif.params->extend({textDocument: docID, content: changeSet})
>
>
--
--
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/CAAW7x7mRr%3D%3D509JYvMpZ8Z6%2Bc92Pj6n%3D1%2BWoeOE5yWYam8oqGw%40mail.gmail.com.