Hi, On Mon, Sep 25, 2023 at 8:26 AM Ernie Rael <[email protected]> wrote: > > Hi all, > > I'm wondering if I'm seeing an error > > ":help lockvar" seems to indicate that the following should work. > The goal is to get a writable variable "l1" that holds a locked list. > > vim9script > var l0: list<list<number>> = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] > var l1 = l0 > lockvar! l1 > unlockvar 0 l1 # <<<<< expect "l1" writable, list still locked >
I see the same problem in a legacy script and from the comments in the var_check_permission function <https://github.com/vim/vim/blob/master/src/evalvars.c#L4047>, it looks like this is done for backward compatibility. Regards, Yegappan > # Not modifying the value, but gets a value locked error > l1 = null_list # E741: Value is locked: l1 > > Can do it this way > > vim9script > > var l0: list<list<number>> = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] > lockvar! l0 > var l1 = l0 > > #l1[0] = [] # fails as exepcted > l1 = null_list # works as expected > > -ernie > -- -- 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/CAAW7x7k7bY%2BxOLKM%2B%3DNsntv7vQ9Lj%3DQMWhWqfRTiOChBXN5fNw%40mail.gmail.com.
