Mercurial > vim
comparison src/userfunc.c @ 21118:b0baa80cb53f v8.2.1110
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Commit: https://github.com/vim/vim/commit/e6b5324e3a3d354363f3c48e784c42ce3e77453f
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jul 1 17:28:33 2020 +0200
patch 8.2.1110: Vim9: line continuation does not work in function arguments
Problem: Vim9: line continuation does not work in function arguments.
Solution: Pass "evalarg" to get_func_tv(). Fix seeing double quoted string
as comment.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 01 Jul 2020 17:30:06 +0200 |
parents | 48cfc37fe4fc |
children | 1f4d0375f947 |
comparison
equal
deleted
inserted
replaced
21117:0aa8873aa305 | 21118:b0baa80cb53f |
---|---|
599 get_func_tv( | 599 get_func_tv( |
600 char_u *name, // name of the function | 600 char_u *name, // name of the function |
601 int len, // length of "name" or -1 to use strlen() | 601 int len, // length of "name" or -1 to use strlen() |
602 typval_T *rettv, | 602 typval_T *rettv, |
603 char_u **arg, // argument, pointing to the '(' | 603 char_u **arg, // argument, pointing to the '(' |
604 evalarg_T *evalarg, // for line continuation | |
604 funcexe_T *funcexe) // various values | 605 funcexe_T *funcexe) // various values |
605 { | 606 { |
606 char_u *argp; | 607 char_u *argp; |
607 int ret = OK; | 608 int ret = OK; |
608 typval_T argvars[MAX_FUNC_ARGS + 1]; // vars for arguments | 609 typval_T argvars[MAX_FUNC_ARGS + 1]; // vars for arguments |
609 int argcount = 0; // number of arguments found | 610 int argcount = 0; // number of arguments found |
610 evalarg_T evalarg; | |
611 | |
612 CLEAR_FIELD(evalarg); | |
613 evalarg.eval_flags = funcexe->evaluate ? EVAL_EVALUATE : 0; | |
614 | 611 |
615 /* | 612 /* |
616 * Get the arguments. | 613 * Get the arguments. |
617 */ | 614 */ |
618 argp = *arg; | 615 argp = *arg; |
619 while (argcount < MAX_FUNC_ARGS - (funcexe->partial == NULL ? 0 | 616 while (argcount < MAX_FUNC_ARGS - (funcexe->partial == NULL ? 0 |
620 : funcexe->partial->pt_argc)) | 617 : funcexe->partial->pt_argc)) |
621 { | 618 { |
622 argp = skipwhite(argp + 1); // skip the '(' or ',' | 619 // skip the '(' or ',' and possibly line breaks |
620 argp = skipwhite_and_linebreak(argp + 1, evalarg); | |
621 | |
623 if (*argp == ')' || *argp == ',' || *argp == NUL) | 622 if (*argp == ')' || *argp == ',' || *argp == NUL) |
624 break; | 623 break; |
625 if (eval1(&argp, &argvars[argcount], &evalarg) == FAIL) | 624 if (eval1(&argp, &argvars[argcount], evalarg) == FAIL) |
626 { | 625 { |
627 ret = FAIL; | 626 ret = FAIL; |
628 break; | 627 break; |
629 } | 628 } |
630 ++argcount; | 629 ++argcount; |
631 if (*argp != ',') | 630 if (*argp != ',') |
632 break; | 631 break; |
633 } | 632 } |
633 argp = skipwhite_and_linebreak(argp, evalarg); | |
634 if (*argp == ')') | 634 if (*argp == ')') |
635 ++argp; | 635 ++argp; |
636 else | 636 else |
637 ret = FAIL; | 637 ret = FAIL; |
638 | 638 |
3830 linenr_T lnum; | 3830 linenr_T lnum; |
3831 int doesrange; | 3831 int doesrange; |
3832 int failed = FALSE; | 3832 int failed = FALSE; |
3833 funcdict_T fudi; | 3833 funcdict_T fudi; |
3834 partial_T *partial = NULL; | 3834 partial_T *partial = NULL; |
3835 | 3835 evalarg_T evalarg; |
3836 | |
3837 fill_evalarg_from_eap(&evalarg, eap, eap->skip); | |
3836 if (eap->skip) | 3838 if (eap->skip) |
3837 { | 3839 { |
3838 // trans_function_name() doesn't work well when skipping, use eval0() | 3840 // trans_function_name() doesn't work well when skipping, use eval0() |
3839 // instead to skip to any following command, e.g. for: | 3841 // instead to skip to any following command, e.g. for: |
3840 // :if 0 | call dict.foo().bar() | endif | 3842 // :if 0 | call dict.foo().bar() | endif |
3841 ++emsg_skip; | 3843 ++emsg_skip; |
3842 if (eval0(eap->arg, &rettv, eap, NULL) != FAIL) | 3844 if (eval0(eap->arg, &rettv, eap, &evalarg) != FAIL) |
3843 clear_tv(&rettv); | 3845 clear_tv(&rettv); |
3844 --emsg_skip; | 3846 --emsg_skip; |
3847 clear_evalarg(&evalarg, eap); | |
3845 return; | 3848 return; |
3846 } | 3849 } |
3847 | 3850 |
3848 tofree = trans_function_name(&arg, NULL, eap->skip, | 3851 tofree = trans_function_name(&arg, NULL, eap->skip, |
3849 TFN_INT, &fudi, &partial); | 3852 TFN_INT, &fudi, &partial); |
3916 funcexe.lastline = eap->line2; | 3919 funcexe.lastline = eap->line2; |
3917 funcexe.doesrange = &doesrange; | 3920 funcexe.doesrange = &doesrange; |
3918 funcexe.evaluate = !eap->skip; | 3921 funcexe.evaluate = !eap->skip; |
3919 funcexe.partial = partial; | 3922 funcexe.partial = partial; |
3920 funcexe.selfdict = fudi.fd_dict; | 3923 funcexe.selfdict = fudi.fd_dict; |
3921 if (get_func_tv(name, -1, &rettv, &arg, &funcexe) == FAIL) | 3924 if (get_func_tv(name, -1, &rettv, &arg, &evalarg, &funcexe) == FAIL) |
3922 { | 3925 { |
3923 failed = TRUE; | 3926 failed = TRUE; |
3924 break; | 3927 break; |
3925 } | 3928 } |
3926 if (has_watchexpr()) | 3929 if (has_watchexpr()) |
3945 if (aborting()) | 3948 if (aborting()) |
3946 break; | 3949 break; |
3947 } | 3950 } |
3948 if (eap->skip) | 3951 if (eap->skip) |
3949 --emsg_skip; | 3952 --emsg_skip; |
3953 clear_evalarg(&evalarg, eap); | |
3950 | 3954 |
3951 // When inside :try we need to check for following "| catch". | 3955 // When inside :try we need to check for following "| catch". |
3952 if (!failed || eap->cstack->cs_trylevel > 0) | 3956 if (!failed || eap->cstack->cs_trylevel > 0) |
3953 { | 3957 { |
3954 // Check for trailing illegal characters and a following command. | 3958 // Check for trailing illegal characters and a following command. |