changeset 23695:e3d77689d356 v8.2.2389

patch 8.2.2389: test failure on a few systems Commit: https://github.com/vim/vim/commit/9b6344613eecfcf77c510d7b63fcc4b7b51aefbc Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jan 21 22:53:38 2021 +0100 patch 8.2.2389: test failure on a few systems Problem: Test failure on a few systems. Solution: Avoid that "char" value is negative.
author Bram Moolenaar <Bram@vim.org>
date Thu, 21 Jan 2021 23:00:05 +0100
parents 7d29116429d0
children c0a8837e86cb
files src/version.c src/vim9.h src/vim9compile.c src/vim9execute.c
diffstat 4 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2389,
+/**/
     2388,
 /**/
     2387,
--- a/src/vim9.h
+++ b/src/vim9.h
@@ -224,7 +224,7 @@ typedef struct {
 // arguments to ISN_CHECKTYPE
 typedef struct {
     type_T	*ct_type;
-    char	ct_off;		// offset in stack, -1 is bottom
+    char	ct_off;		// offset in stack (positive), 1 is bottom
     char	ct_arg_idx;	// argument index or zero
 } checktype_T;
 
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -826,7 +826,9 @@ generate_TYPECHECK(
     if ((isn = generate_instr(cctx, ISN_CHECKTYPE)) == NULL)
 	return FAIL;
     isn->isn_arg.type.ct_type = alloc_type(expected);
-    isn->isn_arg.type.ct_off = offset;
+    // Use the negated offset so that it's always positive.  Some systems don't
+    // support negative numbers for "char".
+    isn->isn_arg.type.ct_off = (char)-offset;
     isn->isn_arg.type.ct_arg_idx = argidx;
 
     // type becomes expected
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -3240,7 +3240,7 @@ call_def_function(
 		{
 		    checktype_T *ct = &iptr->isn_arg.type;
 
-		    tv = STACK_TV_BOT(ct->ct_off);
+		    tv = STACK_TV_BOT(-(int)ct->ct_off);
 		    SOURCING_LNUM = iptr->isn_lnum;
 		    if (check_typval_type(ct->ct_type, tv, ct->ct_arg_idx)
 								       == FAIL)
@@ -4242,11 +4242,11 @@ ex_disassemble(exarg_T *eap)
 		      if (ct->ct_arg_idx == 0)
 			  smsg("%4d CHECKTYPE %s stack[%d]", current,
 					  type_name(ct->ct_type, &tofree),
-					  (int)ct->ct_off);
+					  -(int)ct->ct_off);
 		      else
 			  smsg("%4d CHECKTYPE %s stack[%d] arg %d", current,
 					  type_name(ct->ct_type, &tofree),
-					  (int)ct->ct_off,
+					  -(int)ct->ct_off,
 					  (int)ct->ct_arg_idx);
 		      vim_free(tofree);
 		      break;