Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
17637:698003085267 | 17638:9ffec4eb8d33 |
---|---|
4732 } | 4732 } |
4733 | 4733 |
4734 *arg = skipwhite(*arg); | 4734 *arg = skipwhite(*arg); |
4735 | 4735 |
4736 /* Handle following '[', '(' and '.' for expr[expr], expr.name, | 4736 /* Handle following '[', '(' and '.' for expr[expr], expr.name, |
4737 * expr(expr). */ | 4737 * expr(expr), expr->name(expr) */ |
4738 if (ret == OK) | 4738 if (ret == OK) |
4739 ret = handle_subscript(arg, rettv, evaluate, TRUE); | 4739 ret = handle_subscript(arg, rettv, evaluate, TRUE); |
4740 | 4740 |
4741 /* | 4741 /* |
4742 * Apply logical NOT and unary '-', from right to left, ignore '+'. | 4742 * Apply logical NOT and unary '-', from right to left, ignore '+'. |
4822 // Skip over the ->. | 4822 // Skip over the ->. |
4823 *arg += 2; | 4823 *arg += 2; |
4824 | 4824 |
4825 // Locate the method name. | 4825 // Locate the method name. |
4826 name = *arg; | 4826 name = *arg; |
4827 for (len = 0; ASCII_ISALNUM(name[len]) || name[len] == '_'; ++len) | 4827 for (len = 0; eval_isnamec(name[len]); ++len) |
4828 ; | 4828 ; |
4829 if (len == 0) | 4829 if (len == 0) |
4830 { | 4830 { |
4831 if (verbose) | 4831 if (verbose) |
4832 emsg(_("E260: Missing name after ->")); | 4832 emsg(_("E260: Missing name after ->")); |
4839 if (verbose) | 4839 if (verbose) |
4840 semsg(_(e_missingparen), name); | 4840 semsg(_(e_missingparen), name); |
4841 return FAIL; | 4841 return FAIL; |
4842 } | 4842 } |
4843 *arg += len; | 4843 *arg += len; |
4844 | |
4845 // TODO: if "name" is a function reference, resolve it. | |
4844 | 4846 |
4845 vim_memset(&funcexe, 0, sizeof(funcexe)); | 4847 vim_memset(&funcexe, 0, sizeof(funcexe)); |
4846 funcexe.evaluate = evaluate; | 4848 funcexe.evaluate = evaluate; |
4847 funcexe.basetv = &base; | 4849 funcexe.basetv = &base; |
4848 rettv->v_type = VAR_UNKNOWN; | 4850 rettv->v_type = VAR_UNKNOWN; |