Compare commits

...

4 Commits

Author SHA1 Message Date
Bram Moolenaar
d00a7fb81a patch 8.2.2579: Vim9: crash in garbagecollect after for loop
Problem:    Vim9: crash in garbagecollect after for loop.
Solution:   Do not set a reference in script item when the name was cleared.
            (closes #7935)
2021-03-08 20:47:14 +01:00
Bram Moolenaar
86c3a2162c patch 8.2.2578: Lua cannot handle a passed in lambda
Problem:    Lua cannot handle a passed in lambda.
Solution:   Handle VAR_PARTIAL. (Prabir Shrestha, closes #7937, closes #7936)
2021-03-08 19:50:24 +01:00
Bram Moolenaar
9355ae4149 patch 8.2.2577: compiler warning for type conversion
Problem:    Compiler warning for type conversion.
Solution:   Add a typecast. (Mike Williams)
2021-03-08 19:04:05 +01:00
Bram Moolenaar
608d78fb45 patch 8.2.2576: Vim9: defining a :func function checks for white space
Problem:    Vim9: defining a :func function checks for white space after a
            comma in the arguments.
Solution:   Only check for white space in a :def function. (closes #7930)
2021-03-06 22:33:12 +01:00
7 changed files with 44 additions and 3 deletions

View File

@@ -1034,7 +1034,7 @@ win_line(
p_extra_free = alloc(MAX_MCO * fdc + 1);
if (p_extra_free != NULL)
{
n_extra = fill_foldcolumn(p_extra_free, wp,
n_extra = (int)fill_foldcolumn(p_extra_free, wp,
FALSE, lnum);
p_extra_free[n_extra] = NUL;
p_extra = p_extra_free;

View File

@@ -319,7 +319,8 @@ garbage_collect_scriptvars(int copyID)
{
svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx;
abort = abort || set_ref_in_item(sv->sv_tv, copyID, NULL, NULL);
if (sv->sv_name != NULL)
abort = abort || set_ref_in_item(sv->sv_tv, copyID, NULL, NULL);
}
}

View File

@@ -568,6 +568,11 @@ luaV_pushtypval(lua_State *L, typval_T *tv)
case VAR_FUNC:
luaV_pushfuncref(L, tv->vval.v_string);
break;
case VAR_PARTIAL:
// TODO: handle partial arguments
luaV_pushfuncref(L, partial_name(tv->vval.v_partial));
break;
case VAR_BLOB:
luaV_pushblob(L, tv->vval.v_blob);
break;

View File

@@ -121,6 +121,15 @@ func Test_lua_eval()
lua v = nil
endfunc
" Test luaeval() with lambda
func Test_luaeval_with_lambda()
lua function hello_luaeval_lambda(a, cb) return a .. cb() end
call assert_equal('helloworld',
\ luaeval('hello_luaeval_lambda(_A[1], _A[2])',
\ ['hello', {->'world'}]))
lua hello_luaeval_lambda = nil
endfunc
" Test vim.window()
func Test_lua_window()
e Xfoo2

View File

@@ -1136,6 +1136,23 @@ def Test_arg_type_wrong()
CheckScriptFailure(['def Func5(items)', 'echo "a"'], 'E1077:')
enddef
def Test_white_space_after_comma()
var lines =<< trim END
vim9script
def Func(a: number,b: number)
enddef
END
CheckScriptFailure(lines, 'E1069:')
# OK in legacy function
lines =<< trim END
vim9script
func Func(a,b)
endfunc
END
CheckScriptSuccess(lines)
enddef
def Test_vim9script_call()
var lines =<< trim END
vim9script

View File

@@ -310,7 +310,8 @@ get_function_args(
++p;
// Don't give this error when skipping, it makes the "->" not
// found in "{k,v -> x}" and give a confusing error.
if (!skip && in_vim9script()
// Allow missing space after comma in legacy functions.
if (!skip && argtypes != NULL
&& !IS_WHITE_OR_NUL(*p) && *p != endchar)
{
semsg(_(e_white_space_required_after_str_str), ",", p - 1);

View File

@@ -750,6 +750,14 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
2579,
/**/
2578,
/**/
2577,
/**/
2576,
/**/
2575,
/**/