Patch 8.1.1863
Problem:    Confusing error when using a builtin function as method while it
            does not support that.
Solution:   Add a specific error message.
Files:      src/vim.h, src/evalfunc.c, src/userfunc.c,
            src/testdir/test_method.vim


*** ../vim-8.1.1862/src/vim.h   2019-08-04 20:42:39.815198862 +0200
--- src/vim.h   2019-08-16 22:13:06.627100894 +0200
***************
*** 2518,2523 ****
--- 2518,2524 ----
  #define ERROR_NONE    5
  #define ERROR_OTHER   6
  #define ERROR_DELETED 7
+ #define ERROR_NOTMETHOD       8   // function cannot be used as a method
  
  /* flags for find_name_end() */
  #define FNE_INCL_BR   1       /* include [] in name */
*** ../vim-8.1.1862/src/evalfunc.c      2019-08-16 21:49:17.582152291 +0200
--- src/evalfunc.c      2019-08-16 22:14:19.386674603 +0200
***************
*** 1113,1120 ****
      typval_T  argv[MAX_FUNC_ARGS + 1];
  
      fi = find_internal_func(name);
!     if (fi < 0 || global_functions[fi].f_argtype == 0)
        return ERROR_UNKNOWN;
      if (argcount + 1 < global_functions[fi].f_min_argc)
        return ERROR_TOOFEW;
      if (argcount + 1 > global_functions[fi].f_max_argc)
--- 1113,1122 ----
      typval_T  argv[MAX_FUNC_ARGS + 1];
  
      fi = find_internal_func(name);
!     if (fi < 0)
        return ERROR_UNKNOWN;
+     if (global_functions[fi].f_argtype == 0)
+       return ERROR_NOTMETHOD;
      if (argcount + 1 < global_functions[fi].f_min_argc)
        return ERROR_TOOFEW;
      if (argcount + 1 > global_functions[fi].f_max_argc)
*** ../vim-8.1.1862/src/userfunc.c      2019-08-08 20:49:10.771344293 +0200
--- src/userfunc.c      2019-08-16 22:21:05.296426047 +0200
***************
*** 1678,1683 ****
--- 1678,1688 ----
            case ERROR_UNKNOWN:
                    emsg_funcname(N_("E117: Unknown function: %s"), name);
                    break;
+           case ERROR_NOTMETHOD:
+                   emsg_funcname(
+                              N_("E276: Cannot use function as a method: %s"),
+                                                                        name);
+                   break;
            case ERROR_DELETED:
                    emsg_funcname(N_("E933: Function was deleted: %s"), name);
                    break;
***************
*** 1685,1699 ****
                    emsg_funcname((char *)e_toomanyarg, name);
                    break;
            case ERROR_TOOFEW:
!                   emsg_funcname(N_("E119: Not enough arguments for function: 
%s"),
                                                                        name);
                    break;
            case ERROR_SCRIPT:
!                   emsg_funcname(N_("E120: Using <SID> not in a script 
context: %s"),
                                                                        name);
                    break;
            case ERROR_DICT:
!                   emsg_funcname(N_("E725: Calling dict function without 
Dictionary: %s"),
                                                                        name);
                    break;
        }
--- 1690,1707 ----
                    emsg_funcname((char *)e_toomanyarg, name);
                    break;
            case ERROR_TOOFEW:
!                   emsg_funcname(
!                            N_("E119: Not enough arguments for function: %s"),
                                                                        name);
                    break;
            case ERROR_SCRIPT:
!                   emsg_funcname(
!                          N_("E120: Using <SID> not in a script context: %s"),
                                                                        name);
                    break;
            case ERROR_DICT:
!                   emsg_funcname(
!                     N_("E725: Calling dict function without Dictionary: %s"),
                                                                        name);
                    break;
        }
*** ../vim-8.1.1862/src/testdir/test_method.vim 2019-08-10 00:13:24.712826628 
+0200
--- src/testdir/test_method.vim 2019-08-16 22:21:36.652258867 +0200
***************
*** 134,136 ****
--- 134,140 ----
    " todo: lambda accepts more arguments than it consumes
    " call assert_fails('eval "text"->{x -> x .. " extended"}("more")', 'E99:')
  endfunc
+ 
+ func Test_method_not_supported()
+   call assert_fails('eval 123->changenr()', 'E276:')
+ endfunc
*** ../vim-8.1.1862/src/version.c       2019-08-16 21:54:23.684691636 +0200
--- src/version.c       2019-08-16 22:17:50.897480320 +0200
***************
*** 771,772 ****
--- 771,774 ----
  {   /* Add new patch number below this line */
+ /**/
+     1863,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
71. You wonder how people walk

 /// 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/201908162023.x7GKN25v029367%40masaka.moolenaar.net.

Raspunde prin e-mail lui