[vim/vim] class/lockvar interaction problem (Issue #12881)

8 views
Skip to first unread message

errael

unread,
Aug 21, 2023, 8:08:18 PM8/21/23
to vim/vim, Subscribed

Steps to reproduce

(Note running with #12868, doubt that that matters)
Source this script

vim9script

class C
    this.val: number
    def new(this.val)
    enddef
endclass

var some_dict: dict<C> = { a: C.new(1), b: C.new(2), c: C.new(3), }

lockvar 2 some_dict

var current: C

current = some_dict['c'] | echo 'A:' current
current = some_dict['b'] | echo 'B:' current

def F()
    current = some_dict['c']
enddef

def G()
    current = some_dict['b']
enddef

F() | echo 'C:' current
G() | echo 'D:' current

echo some_dict

Observe this output

A: object of C {val: 3}
B: object of C {val: 2}
C: object of C {val: 3}
Error detected while processing command line..script /home/err/bugs/vim/classlock/lockclass.vim[27].
.function <SNR>34_G:
line    1:
E741: Value is locked: current

There's no attempt at modified the locked structures. Notice that it works at script level.

Source the following, which uses a list instead of a class in some_dict and there is no problem

vim9script

var some_dict: dict<list<number>> = { a: [1], b: [2], c: [3], }

lockvar 2 some_dict

var current: list<number>

current = some_dict['c'] | echo 'A:' current
current = some_dict['b'] | echo 'B:' current

def F()
    current = some_dict['c']
enddef

def G()
    current = some_dict['b']
enddef

F() | echo 'C:' current
G() | echo 'D:' current

#some_dict['a'] = [11]

echo some_dict

Expected behaviour

No error.

Version of Vim

9.0.1778 + PR#12868

Environment

linux

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12881@github.com>

Yegappan Lakshmanan

unread,
Aug 21, 2023, 10:11:59 PM8/21/23
to vim/vim, Subscribed

This is a bug not related to #12868. I have updated the PR with a fix for this issue.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12881/1687308720@github.com>

Christian Brabandt

unread,
Aug 22, 2023, 3:36:07 PM8/22/23
to vim/vim, Subscribed

Closed #12881 as completed via 618e47d.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/12881/issue_event/10162403029@github.com>

Reply all
Reply to author
Forward
0 new messages