Patch 8.2.0483

7 views
Skip to first unread message

Bram Moolenaar

unread,
Mar 30, 2020, 3:06:22 PM3/30/20
to vim...@googlegroups.com

Patch 8.2.0483
Problem: Vim9: "let x = x + 1" does not give an error.
Solution: Hide the variable when compiling the expression.
Files: src/vim9compile.c, src/testdir/test_vim9_expr.vim


*** ../vim-8.2.0482/src/vim9compile.c 2020-03-29 21:38:10.277149761 +0200
--- src/vim9compile.c 2020-03-30 21:04:28.794831393 +0200
***************
*** 3685,3690 ****
--- 3685,3692 ----
}
else if (oplen > 0)
{
+ int r;
+
// for "+=", "*=", "..=" etc. first load the current value
if (*op != '=')
{
***************
*** 3717,3726 ****
}
}

! // compile the expression
instr_count = instr->ga_len;
p = skipwhite(p + oplen);
! if (compile_expr1(&p, cctx) == FAIL)
goto theend;

if (idx >= 0 && (is_decl || !has_type))
--- 3719,3734 ----
}
}

! // Compile the expression. Temporarily hide the new local variable
! // here, it is not available to this expression.
! if (idx >= 0)
! --cctx->ctx_locals.ga_len;
instr_count = instr->ga_len;
p = skipwhite(p + oplen);
! r = compile_expr1(&p, cctx);
! if (idx >= 0)
! ++cctx->ctx_locals.ga_len;
! if (r == FAIL)
goto theend;

if (idx >= 0 && (is_decl || !has_type))
*** ../vim-8.2.0482/src/testdir/test_vim9_expr.vim 2020-03-29 21:38:10.277149761 +0200
--- src/testdir/test_vim9_expr.vim 2020-03-30 21:04:54.694750516 +0200
***************
*** 738,743 ****
--- 738,745 ----
call CheckDefFailure("let x = {'a': xxx}", 'E1001:')
call CheckDefFailure("let x = {xxx: 8}", 'E1001:')
call CheckDefFailure("let x = #{a: 1, a: 2}", 'E721:')
+ call CheckDefFailure("let x += 1", 'E1020:')
+ call CheckDefFailure("let x = x + 1", 'E1001:')
call CheckDefExecFailure("let x = g:anint.member", 'E715:')
call CheckDefExecFailure("let x = g:dict_empty.member", 'E716:')
enddef
*** ../vim-8.2.0482/src/version.c 2020-03-30 19:30:07.133542905 +0200
--- src/version.c 2020-03-30 21:05:27.738647194 +0200
***************
*** 740,741 ****
--- 740,743 ----
{ /* Add new patch number below this line */
+ /**/
+ 483,
/**/

--
Vi beats Emacs to death, and then again!
http://linuxtoday.com/stories/5764.html

/// 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