diff src/eval.c @ 17638:9ffec4eb8d33 v8.1.1816

patch 8.1.1816: cannot use a user defined function as a method commit https://github.com/vim/vim/commit/fcfe1a9b8950b8b211ab3b24d84b17c6847ea43f Author: Bram Moolenaar <Bram@vim.org> Date: Sun Aug 4 23:04:39 2019 +0200 patch 8.1.1816: cannot use a user defined function as a method Problem: Cannot use a user defined function as a method. Solution: Pass the base as the first argument to the user defined function after "->". (partly by FUJIWARA Takuya)
author Bram Moolenaar <Bram@vim.org>
date Sun, 04 Aug 2019 23:15:05 +0200
parents e259d11e2900
children e5397617d6ca
line wrap: on
line diff
--- a/src/eval.c
+++ b/src/eval.c
@@ -4734,7 +4734,7 @@ eval7(
     *arg = skipwhite(*arg);
 
     /* Handle following '[', '(' and '.' for expr[expr], expr.name,
-     * expr(expr). */
+     * expr(expr), expr->name(expr) */
     if (ret == OK)
 	ret = handle_subscript(arg, rettv, evaluate, TRUE);
 
@@ -4824,7 +4824,7 @@ eval_method(
 
     // Locate the method name.
     name = *arg;
-    for (len = 0; ASCII_ISALNUM(name[len]) || name[len] == '_'; ++len)
+    for (len = 0; eval_isnamec(name[len]); ++len)
 	;
     if (len == 0)
     {
@@ -4842,6 +4842,8 @@ eval_method(
     }
     *arg += len;
 
+    // TODO: if "name" is a function reference, resolve it.
+
     vim_memset(&funcexe, 0, sizeof(funcexe));
     funcexe.evaluate = evaluate;
     funcexe.basetv = &base;