diff src/vim9compile.c @ 24329:cd9f77409393 v8.2.2705

patch 8.2.2705: Vim9: misleading reported line number for wrong type Commit: https://github.com/vim/vim/commit/77709b194c71eb02f765521f31b463593bd07cda Author: Bram Moolenaar <Bram@vim.org> Date: Sat Apr 3 21:01:01 2021 +0200 patch 8.2.2705: Vim9: misleading reported line number for wrong type Problem: Vim9: misleading reported line number for wrong type. Solution: Remember and use the line number at the start. (closes https://github.com/vim/vim/issues/8059)
author Bram Moolenaar <Bram@vim.org>
date Sat, 03 Apr 2021 21:15:03 +0200
parents 7f634eae21fe
children bd010982f0be
line wrap: on
line diff
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -6166,6 +6166,7 @@ compile_assignment(char_u *arg, exarg_T 
     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,7 +6394,9 @@ compile_assignment(char_u *arg, exarg_T 
 		    {
 			type_T *use_type = lhs.lhs_lvar->lv_type;
 
-			// without operator check type here, otherwise below
+			// 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,