Patch 8.2.2618

2 views
Skip to first unread message

Bram Moolenaar

unread,
Mar 17, 2021, 3:57:32 PM3/17/21
to vim...@googlegroups.com

Patch 8.2.2618
Problem: Vim9: cannot use a normal list name to store function refs.
Solution: Allow a lower case name if it is indexed.
Files: src/vim9compile.c, src/testdir/test_vim9_assign.vim


*** ../vim-8.2.2617/src/vim9compile.c 2021-03-17 18:42:04.442869185 +0100
--- src/vim9compile.c 2021-03-17 20:55:38.077197900 +0100
***************
*** 5832,5842 ****
return FAIL;
}

! // new local variable
if ((lhs->lhs_type->tt_type == VAR_FUNC
|| lhs->lhs_type->tt_type == VAR_PARTIAL)
! && var_wrong_func_name(lhs->lhs_name, TRUE))
return FAIL;
lhs->lhs_lvar = reserve_local(cctx, var_start, lhs->lhs_varlen,
cmdidx == CMD_final || cmdidx == CMD_const, lhs->lhs_type);
if (lhs->lhs_lvar == NULL)
--- 5832,5844 ----
return FAIL;
}

! // Check the name is valid for a funcref.
if ((lhs->lhs_type->tt_type == VAR_FUNC
|| lhs->lhs_type->tt_type == VAR_PARTIAL)
! && var_wrong_func_name(lhs->lhs_name, TRUE))
return FAIL;
+
+ // New local variable.
lhs->lhs_lvar = reserve_local(cctx, var_start, lhs->lhs_varlen,
cmdidx == CMD_final || cmdidx == CMD_const, lhs->lhs_type);
if (lhs->lhs_lvar == NULL)
***************
*** 6275,6280 ****
--- 6277,6283 ----
{
if ((rhs_type->tt_type == VAR_FUNC
|| rhs_type->tt_type == VAR_PARTIAL)
+ && !lhs.lhs_has_index
&& var_wrong_func_name(lhs.lhs_name, TRUE))
goto theend;

*** ../vim-8.2.2617/src/testdir/test_vim9_assign.vim 2021-03-03 17:58:12.009789245 +0100
--- src/testdir/test_vim9_assign.vim 2021-03-17 20:53:52.453409282 +0100
***************
*** 72,77 ****
--- 72,84 ----
CheckDefFailure(['var lambda = () => "lambda"'], 'E704:')
CheckScriptFailure(['var x = "x"'], 'E1124:')

+ # lower case name is OK for a list
+ var lambdaLines =<< trim END
+ var lambdaList: list<func> = [Test_syntax]
+ lambdaList[0] = () => "lambda"
+ END
+ CheckDefAndScriptSuccess(lambdaLines)
+
var nr: number = 1234
CheckDefFailure(['var nr: number = "asdf"'], 'E1012:')

*** ../vim-8.2.2617/src/version.c 2021-03-17 18:42:04.442869185 +0100
--- src/version.c 2021-03-17 20:56:00.789152157 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2618,
/**/

--
EXPERIENCE - experience is a wonderful thing. It enables you to
recognise a mistake when you make it again.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages