diff options
author | Bram Moolenaar <Bram@vim.org> | 2023-01-27 20:14:02 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-27 20:14:02 +0000 |
commit | 8dbab1d8ceb82a0fb693a1b7fcb57a2dfb4de068 (patch) | |
tree | d4e6d32b34dcfbd00784c297ff1139079eb47f44 /src/vim9cmds.c | |
parent | 657aea7fc47fb919ce76fad64ba0ec55a1af80f1 (diff) | |
download | vim-git-8dbab1d8ceb82a0fb693a1b7fcb57a2dfb4de068.tar.gz |
patch 9.0.1250: cannot use an object method with :deferv9.0.1250
Problem: Cannot use an object method with :defer. (Ernie Rael)
Solution: Find the object method and generate code to call it.
(closes #11886)
Diffstat (limited to 'src/vim9cmds.c')
-rw-r--r-- | src/vim9cmds.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/vim9cmds.c b/src/vim9cmds.c index 763d8b3b8..69c04aec9 100644 --- a/src/vim9cmds.c +++ b/src/vim9cmds.c @@ -1910,6 +1910,7 @@ compile_defer(char_u *arg_start, cctx_T *cctx) int defer_var_idx; type_T *type; int func_idx; + int obj_method = 0; // Get a funcref for the function name. // TODO: better way to find the "(". @@ -1925,8 +1926,15 @@ compile_defer(char_u *arg_start, cctx_T *cctx) // TODO: better type generate_PUSHFUNC(cctx, (char_u *)internal_func_name(func_idx), &t_func_any, FALSE); - else if (compile_expr0(&arg, cctx) == FAIL) - return NULL; + else + { + int typecount = cctx->ctx_type_stack.ga_len; + if (compile_expr0(&arg, cctx) == FAIL) + return NULL; + if (cctx->ctx_type_stack.ga_len >= typecount + 2) + // must have seen "obj.Func", pushed an object and a function + obj_method = 1; + } *paren = '('; // check for function type @@ -1958,7 +1966,7 @@ compile_defer(char_u *arg_start, cctx_T *cctx) defer_var_idx = get_defer_var_idx(cctx); if (defer_var_idx == 0) return NULL; - if (generate_DEFER(cctx, defer_var_idx - 1, argcount) == FAIL) + if (generate_DEFER(cctx, defer_var_idx - 1, obj_method, argcount) == FAIL) return NULL; return skipwhite(arg); |