forked from aniani/vim
patch 9.1.0261: Vim9: protected class and funcrefs accessible outside the class
Problem: Vim9: protected class and funcrefs accessible outside the class
(Aliaksei Budavei)
Solution: Check if class and object funcrefs are protected
(Yegappan)
closes: #14407
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
bd28cae1f1
commit
3e33650b3a
@@ -10530,4 +10530,27 @@ def Test_use_base_class_variable_from_base_class_method()
|
||||
v9.CheckScriptSuccess(lines)
|
||||
enddef
|
||||
|
||||
" Test for accessing protected funcref object and class variables
|
||||
def Test_protected_funcref()
|
||||
# protected funcref object variable
|
||||
var lines =<< trim END
|
||||
vim9script
|
||||
class Test1
|
||||
const _Id: func(any): any = (v) => v
|
||||
endclass
|
||||
var n = Test1.new()._Id(1)
|
||||
END
|
||||
v9.CheckScriptFailure(lines, 'E1333: Cannot access protected variable "_Id" in class "Test1"', 5)
|
||||
|
||||
# protected funcref class variable
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
class Test2
|
||||
static const _Id: func(any): any = (v) => v
|
||||
endclass
|
||||
var n = Test2._Id(2)
|
||||
END
|
||||
v9.CheckScriptFailure(lines, 'E1333: Cannot access protected variable "_Id" in class "Test2"', 5)
|
||||
enddef
|
||||
|
||||
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
|
||||
|
||||
Reference in New Issue
Block a user