Patch 8.2.2705
Problem: Vim9: misleading reported line number for wrong type.
Solution: Remember and use the line number at the start. (closes #8059)
Files: src/vim9compile.c, src/testdir/test_vim9_assign.vim
*** ../vim-8.2.2704/src/vim9compile.c 2021-04-01 21:38:46.753298941 +0200
--- src/vim9compile.c 2021-04-03 20:57:18.436618058 +0200
***************
*** 6166,6171 ****
--- 6166,6172 ----
char_u *sp;
int is_decl = is_decl_command(cmdidx);
lhs_T lhs;
+ long start_lnum = SOURCING_LNUM;
// Skip over the "var" or "[var, var]" to get to any "=".
p = skip_var_list(arg, TRUE, &var_count, &semicolon, TRUE);
***************
*** 6393,6399 ****
{
type_T *use_type = lhs.lhs_lvar->lv_type;
! // without operator check type here, otherwise below
if (lhs.lhs_has_index)
use_type = lhs.lhs_member_type;
if (need_type(rhs_type, use_type, -1, 0, cctx,
--- 6394,6402 ----
{
type_T *use_type = lhs.lhs_lvar->lv_type;
! // Without operator check type here, otherwise below.
! // Use the line number of the assignment.
! SOURCING_LNUM = start_lnum;
if (lhs.lhs_has_index)
use_type = lhs.lhs_member_type;
if (need_type(rhs_type, use_type, -1, 0, cctx,
*** ../vim-8.2.2704/src/testdir/test_vim9_assign.vim 2021-04-03 19:32:40.750286283 +0200
--- src/testdir/test_vim9_assign.vim 2021-04-03 20:56:59.008653929 +0200
***************
*** 315,320 ****
--- 315,328 ----
assert_equal(34, n2)
CheckDefFailure(["var x = #"], 'E1097:', 3)
+
+ var lines =<< trim END
+ var x: list<string> = ['a']
+ var y: list<number> = x
+ ->copy()
+ ->copy()
+ END
+ CheckDefFailure(lines, 'E1012:', 2)
enddef
def Test_assign_index()
*** ../vim-8.2.2704/src/version.c 2021-04-03 20:13:25.594782463 +0200
--- src/version.c 2021-04-03 20:55:11.348843204 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2705,
/**/
--
Master: Boy, there is nothing more for you to learn
Student: I didn't know that!
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///