patch 8.2.1479: Vim9: error for list index uses wrong line number

Problem:    Vim9: error for list index uses wrong line number.
Solution:   Set source line number. (closes #6724)  Add a way to assert the
            line number of the error with assert_fails().
diff --git a/src/testing.c b/src/testing.c
index 137d5fe..0971876 100644
--- a/src/testing.c
+++ b/src/testing.c
@@ -142,7 +142,10 @@
     int		did_copy = FALSE;
     int		omitted = 0;
 
-    if (opt_msg_tv->v_type != VAR_UNKNOWN)
+    if (opt_msg_tv->v_type != VAR_UNKNOWN
+	    && !(opt_msg_tv->v_type == VAR_STRING
+		&& (opt_msg_tv->vval.v_string == NULL
+		    || *opt_msg_tv->vval.v_string == NUL)))
     {
 	ga_concat(gap, echo_string(opt_msg_tv, &tofree, numbuf, 0));
 	vim_free(tofree);
@@ -570,6 +573,7 @@
 	char_u	buf[NUMBUFLEN];
 	char_u	*expected;
 	int	error_found = FALSE;
+	int	lnum_error_found = FALSE;
 	char_u	*actual = emsg_assert_fails_msg == NULL ? (char_u *)"[unknown]"
 						       : emsg_assert_fails_msg;
 
@@ -611,14 +615,31 @@
 	    goto theend;
 	}
 
+	if (!error_found && argvars[3].v_type == VAR_NUMBER
+		&& argvars[3].vval.v_number >= 0
+		&& argvars[3].vval.v_number != emsg_assert_fails_lnum)
+	{
+	    error_found = TRUE;
+	    lnum_error_found = TRUE;
+	}
+
 	if (error_found)
 	{
 	    typval_T actual_tv;
 
 	    prepare_assert_error(&ga);
-	    actual_tv.v_type = VAR_STRING;
-	    actual_tv.vval.v_string = actual;
-	    fill_assert_error(&ga, &argvars[2], NULL, &argvars[1],
+	    if (lnum_error_found)
+	    {
+		actual_tv.v_type = VAR_NUMBER;
+		actual_tv.vval.v_number = emsg_assert_fails_lnum;
+	    }
+	    else
+	    {
+		actual_tv.v_type = VAR_STRING;
+		actual_tv.vval.v_string = actual;
+	    }
+	    fill_assert_error(&ga, &argvars[2], NULL,
+		    &argvars[lnum_error_found ? 3 : 1],
 						     &actual_tv, ASSERT_OTHER);
 	    ga_concat(&ga, (char_u *)": ");
 	    assert_append_cmd_or_arg(&ga, argvars, cmd);