Mercurial > vim
comparison src/testdir/test_vim9_class.vim @ 34769:d4fb6ea26ae4 v9.1.0261
patch 9.1.0261: Vim9: protected class and funcrefs accessible outside the class
Commit: https://github.com/vim/vim/commit/3e33650b3a9939f6b942c1d1eccdb261ea17a647
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Thu Apr 4 19:35:59 2024 +0200
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>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 04 Apr 2024 19:45:10 +0200 |
parents | a14868d39709 |
children | af48c532bd88 |
comparison
equal
deleted
inserted
replaced
34768:1faaf5fdbb06 | 34769:d4fb6ea26ae4 |
---|---|
10528 assert_equal(2, DictKeyClass.GetIdCount()) | 10528 assert_equal(2, DictKeyClass.GetIdCount()) |
10529 END | 10529 END |
10530 v9.CheckScriptSuccess(lines) | 10530 v9.CheckScriptSuccess(lines) |
10531 enddef | 10531 enddef |
10532 | 10532 |
10533 " Test for accessing protected funcref object and class variables | |
10534 def Test_protected_funcref() | |
10535 # protected funcref object variable | |
10536 var lines =<< trim END | |
10537 vim9script | |
10538 class Test1 | |
10539 const _Id: func(any): any = (v) => v | |
10540 endclass | |
10541 var n = Test1.new()._Id(1) | |
10542 END | |
10543 v9.CheckScriptFailure(lines, 'E1333: Cannot access protected variable "_Id" in class "Test1"', 5) | |
10544 | |
10545 # protected funcref class variable | |
10546 lines =<< trim END | |
10547 vim9script | |
10548 class Test2 | |
10549 static const _Id: func(any): any = (v) => v | |
10550 endclass | |
10551 var n = Test2._Id(2) | |
10552 END | |
10553 v9.CheckScriptFailure(lines, 'E1333: Cannot access protected variable "_Id" in class "Test2"', 5) | |
10554 enddef | |
10555 | |
10533 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker | 10556 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker |