summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-12 19:42:01 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-12 19:42:01 +0200
commitfd77748df2ba7d5f38aab649cb630374620462d7 (patch)
tree68ca76560bb073e21f773dc1eb85fb6cf0a9fe6b
parentba60cc45e786166767ca80f3dea6236d993c7971 (diff)
downloadvim-git-fd77748df2ba7d5f38aab649cb630374620462d7.tar.gz
patch 8.2.1434: Vim9: crash when lambda uses outer function argumentv8.2.1434
Problem: Vim9: crash when lambda uses outer function argument. Solution: Set the flag that the outer context is used.
-rw-r--r--src/testdir/test_vim9_expr.vim13
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c3
3 files changed, 18 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index d6313d363..795ea752d 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -1443,6 +1443,16 @@ def LambdaWithComments(): func
}
enddef
+def LambdaUsingArg(x: number): func
+ return {->
+ # some comment
+ x == 1
+ # some comment
+ ||
+ x == 2
+ }
+enddef
+
def Test_expr7_lambda()
let La = { -> 'result'}
assert_equal('result', La())
@@ -1481,6 +1491,9 @@ def Test_expr7_lambda()
assert_equal(true, LambdaWithComments()(2))
assert_equal(false, LambdaWithComments()(3))
+ assert_equal(false, LambdaUsingArg(0)())
+ assert_equal(true, LambdaUsingArg(1)())
+
call CheckDefFailure(["filter([1, 2], {k,v -> 1})"], 'E1069:')
enddef
diff --git a/src/version.c b/src/version.c
index e182ea6aa..110081878 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1434,
+/**/
1433,
/**/
1432,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 87bb0e2c7..889a5d5c9 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -2135,7 +2135,10 @@ compile_load(char_u **arg, char_u *end_arg, cctx_T *cctx, int error)
if (gen_load)
res = generate_LOAD(cctx, ISN_LOAD, idx, NULL, type);
if (gen_load_outer)
+ {
res = generate_LOAD(cctx, ISN_LOADOUTER, idx, NULL, type);
+ cctx->ctx_outer_used = TRUE;
+ }
}
*arg = end;