mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -07:00
vim-patch:8.2.2921: E704 for script local variable is not backwards compatible
Problem: E704 for script local variable is not backwards compatible.
(Yasuhiro Matsumoto)
Solution: Only give the error in Vim9 script. Also check for function-local
variable.
b54abeeafb
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
6b3db3f929
commit
4740672b37
@ -2210,10 +2210,7 @@ bool tv_dict_get_callback(dict_T *const d, const char *const key, const ptrdiff_
|
||||
/// If the name is wrong give an error message and return true.
|
||||
int tv_dict_wrong_func_name(dict_T *d, typval_T *tv, const char *name)
|
||||
{
|
||||
return (d == &globvardict
|
||||
// || (SCRIPT_ID_VALID(current_sctx.sc_sid)
|
||||
// && d == &SCRIPT_ITEM(current_sctx.sc_sid)->sn_vars->sv_dict)
|
||||
)
|
||||
return (d == &globvardict || &d->dv_hashtab == get_funccal_local_ht())
|
||||
&& (tv->v_type == VAR_FUNC || tv->v_type == VAR_PARTIAL)
|
||||
&& var_wrong_func_name(name, true);
|
||||
}
|
||||
|
@ -2486,8 +2486,13 @@ endfunc
|
||||
func Test_builtin_check()
|
||||
call assert_fails('let g:["trim"] = {x -> " " .. x}', 'E704:')
|
||||
call assert_fails('let g:.trim = {x -> " " .. x}', 'E704:')
|
||||
call assert_fails('let s:["trim"] = {x -> " " .. x}', 'E704:')
|
||||
call assert_fails('let s:.trim = {x -> " " .. x}', 'E704:')
|
||||
call assert_fails('let l:["trim"] = {x -> " " .. x}', 'E704:')
|
||||
call assert_fails('let l:.trim = {x -> " " .. x}', 'E704:')
|
||||
let lines =<< trim END
|
||||
vim9script
|
||||
var s:trim = (x) => " " .. x
|
||||
END
|
||||
" call CheckScriptFailure(lines, 'E704:')
|
||||
|
||||
call assert_fails('call extend(g:, #{foo: { -> "foo" }})', 'E704:')
|
||||
let g:bar = 123
|
||||
|
Loading…
Reference in New Issue
Block a user