Skip to content

Commit c6ba2f9

Browse files
committed
patch 8.2.3175: Vim9: using illegal pointer with nested lambdas.
Problem: Vim9: using illegal pointer with inline function inside a lambda. Solution: Clear eval_tofree_cmdline when advancing to the next line. (closes #8578)
1 parent 47bc9c3 commit c6ba2f9

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/eval.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2177,6 +2177,11 @@ eval_next_line(evalarg_T *evalarg)
21772177
vim_free(evalarg->eval_tofree);
21782178
evalarg->eval_tofree = line;
21792179
}
2180+
2181+
// Advanced to the next line, "arg" no longer points into the previous
2182+
// line.
2183+
VIM_CLEAR(evalarg->eval_tofree_cmdline);
2184+
21802185
return skipwhite(line);
21812186
}
21822187

src/testdir/test_vim9_func.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,22 @@ def Test_nested_inline_lambda()
22652265
})
22662266
END
22672267
CheckScriptSuccess(lines)
2268+
2269+
lines =<< trim END
2270+
vim9script
2271+
2272+
def s:func()
2273+
range(10)
2274+
->mapnew((_, _) => ({
2275+
key: range(10)->mapnew((_, _) => {
2276+
return ' '
2277+
}),
2278+
}))
2279+
enddef
2280+
2281+
defcomp
2282+
END
2283+
CheckScriptSuccess(lines)
22682284
enddef
22692285

22702286
def Shadowed(): list<number>

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3175,
758760
/**/
759761
3174,
760762
/**/

0 commit comments

Comments
 (0)