mirror of
https://github.com/vim/vim.git
synced 2025-09-28 04:24:06 -04:00
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
@@ -3794,6 +3794,43 @@ func Test_funcref_to_string()
|
||||
call assert_equal("function('g:Test_funcref_to_string')", string(Fn))
|
||||
endfunc
|
||||
|
||||
" A funcref cannot start with an underscore (except when used as a protected
|
||||
" class or object variable)
|
||||
func Test_funcref_with_underscore()
|
||||
" at script level
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
var _Fn = () => 10
|
||||
END
|
||||
call v9.CheckSourceFailure(lines, 'E704: Funcref variable name must start with a capital: _Fn')
|
||||
|
||||
" inside a function
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
def Func()
|
||||
var _Fn = () => 10
|
||||
enddef
|
||||
defcompile
|
||||
END
|
||||
call v9.CheckSourceFailure(lines, 'E704: Funcref variable name must start with a capital: _Fn', 1)
|
||||
|
||||
" as a function argument
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
def Func(_Fn: func)
|
||||
enddef
|
||||
defcompile
|
||||
END
|
||||
call v9.CheckSourceFailure(lines, 'E704: Funcref variable name must start with a capital: _Fn', 2)
|
||||
|
||||
" as a lambda argument
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
var Fn = (_Farg: func) => 10
|
||||
END
|
||||
call v9.CheckSourceFailure(lines, 'E704: Funcref variable name must start with a capital: _Farg', 2)
|
||||
endfunc
|
||||
|
||||
" Test for isabsolutepath()
|
||||
func Test_isabsolutepath()
|
||||
call assert_false(isabsolutepath(''))
|
||||
|
Reference in New Issue
Block a user