Patch 8.2.2390
Problem:    Vim9: using positive offset is unexpected.
Solution:   Use int8_T instead of char. (James McCoy)
Files:      src/vim9.h, src/vim9compile.c, src/vim9execute.c


*** ../vim-8.2.2389/src/vim9.h  2021-01-21 22:53:33.914809307 +0100
--- src/vim9.h  2021-01-22 17:47:40.943381281 +0100
***************
*** 224,231 ****
  // arguments to ISN_CHECKTYPE
  typedef struct {
      type_T    *ct_type;
!     char      ct_off;         // offset in stack (positive), 1 is bottom
!     char      ct_arg_idx;     // argument index or zero
  } checktype_T;
  
  // arguments to ISN_STORENR
--- 224,231 ----
  // arguments to ISN_CHECKTYPE
  typedef struct {
      type_T    *ct_type;
!     int8_T    ct_off;         // offset in stack, -1 is bottom
!     int8_T    ct_arg_idx;     // argument index or zero
  } checktype_T;
  
  // arguments to ISN_STORENR
*** ../vim-8.2.2389/src/vim9compile.c   2021-01-21 22:53:33.914809307 +0100
--- src/vim9compile.c   2021-01-22 17:48:21.071259201 +0100
***************
*** 826,835 ****
      if ((isn = generate_instr(cctx, ISN_CHECKTYPE)) == NULL)
        return FAIL;
      isn->isn_arg.type.ct_type = alloc_type(expected);
!     // 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
      ((type_T **)stack->ga_data)[stack->ga_len + offset] = expected;
--- 826,833 ----
      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 = (int8_T)offset;
!     isn->isn_arg.type.ct_arg_idx = (int8_T)argidx;
  
      // type becomes expected
      ((type_T **)stack->ga_data)[stack->ga_len + offset] = expected;
*** ../vim-8.2.2389/src/vim9execute.c   2021-01-21 22:53:33.914809307 +0100
--- src/vim9execute.c   2021-01-22 17:49:41.391016026 +0100
***************
*** 3240,3246 ****
                {
                    checktype_T *ct = &iptr->isn_arg.type;
  
!                   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)
--- 3240,3246 ----
                {
                    checktype_T *ct = &iptr->isn_arg.type;
  
!                   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,4252 ****
                      if (ct->ct_arg_idx == 0)
                          smsg("%4d CHECKTYPE %s stack[%d]", current,
                                          type_name(ct->ct_type, &tofree),
!                                         -(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_arg_idx);
                      vim_free(tofree);
                      break;
--- 4242,4252 ----
                      if (ct->ct_arg_idx == 0)
                          smsg("%4d CHECKTYPE %s stack[%d]", current,
                                          type_name(ct->ct_type, &tofree),
!                                         (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_arg_idx);
                      vim_free(tofree);
                      break;
*** ../vim-8.2.2389/src/version.c       2021-01-21 22:53:33.914809307 +0100
--- src/version.c       2021-01-22 17:50:41.986833458 +0100
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2390,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
206. You religiously respond immediately to e-mail, while ignoring
     your growing pile of snail mail.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202101221712.10MHCVON2249396%40masaka.moolenaar.net.

Raspunde prin e-mail lui