]> granicus.if.org Git - vim/commitdiff
patch 8.2.2389: test failure on a few systems v8.2.2389
authorBram Moolenaar <Bram@vim.org>
Thu, 21 Jan 2021 21:53:38 +0000 (22:53 +0100)
committerBram Moolenaar <Bram@vim.org>
Thu, 21 Jan 2021 21:53:38 +0000 (22:53 +0100)
Problem:    Test failure on a few systems.
Solution:   Avoid that "char" value is negative.

src/version.c
src/vim9.h
src/vim9compile.c
src/vim9execute.c

index 6d99990cd3879c33e40f87d8170f0bda2ef0ea89..568756b85f09d16d04dce26ff9565e288f4df8d0 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2389,
 /**/
     2388,
 /**/
index c51be8ef626071393112f51e49dd422343c6de3a..e6c4087c617df189715e534c8532a5b4a6c863b9 100644 (file)
@@ -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;
 
index ead971feba45f43381a36a61ee10b6e50be65c7f..2fad4ac34b736dad19dc3631d672d9f429453d37 100644 (file)
@@ -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
index 7d1d079bb19c93db677dffb69380298b58ab9cd6..b5f4be34e3f6e99af5864f3a4497d40c335c4020 100644 (file)
@@ -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;