Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG] Anonymous functions cause funcfiletrace to produce function-relative line numbers
- X-seq: zsh-workers 42108
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [BUG] Anonymous functions cause funcfiletrace to produce function-relative line numbers
- Date: Mon, 11 Dec 2017 09:41:16 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20171211094121euoutp015c369a974868646e76707076eefaf08a~-NBjSqcl83054530545euoutp01u
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1512985281; bh=ep45hZ65WSCkQBbEBm3ppD6Ft9xBzgKmu/H7NQV6Apc=; h=Date:From:To:Subject:In-reply-to:References:From; b=UAJdxwMHf4G+Jg5AlLAxEnUYxWn24pDdOjApTz6B1+lqtCIslvPmTQJcAbHDIyhE6 6gE2hkIok/HCqB1OJxFnXItcBpbQnS0RoLzBHrzU+HPb5KRFXzfKLJKkiF0jUsaoV+ tXg2V6g2UUGfk8Qj8r0Toedna8vBEa5rFY2Z7L8k=
- In-reply-to: <E7CE1AD5-1169-46C2-9776-1C9B9BDEEB9B@dana.is>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CGME20171210232854epcas2p2f9d4f0ac2ad31feb5a54d61da49e7140@epcas2p2.samsung.com> <E7CE1AD5-1169-46C2-9776-1C9B9BDEEB9B@dana.is>
On Sun, 10 Dec 2017 17:28:03 -0600
dana <dana@xxxxxxx> wrote:
> I was experimenting with line-number tracing today and i found that anonymous
> functions have an undesirable effect on funcfiletrace:
>
> % cat -n tracetest.zsh
> 1 #
> 2 foo() {
> 3 #
> 4 #
> 5 #
> 6 #
> 7 #
> 8 () { () { print -rC2 -- $functrace $funcfiletrace } }
> 9 }
> 10 foo
> % zsh tracetest.zsh
> (anon):0 tracetest.zsh:6
> foo:6 tracetest.zsh:8
> tracetest.zsh:10 tracetest.zsh:10
>
> Note that the top call from (anon) is listed as tracetest.zsh:6 (actually the
> relative line number within the function foo) rather than the expected
> tracetest.zsh:8 (the absolute line number within the file).
I don't think this is just anonymous functions; I think the problem is
the temptation to use nested functions is just greater with anonymous
functions.
Perhaps...?
pws
diff --git a/Src/exec.c b/Src/exec.c
index fc6d02d..03b7f3d 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5669,11 +5669,11 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
funcsave->fstack.caller = funcstack ? funcstack->name :
dupstring(funcsave->argv0 ? funcsave->argv0 : argzero);
funcsave->fstack.lineno = lineno;
+ funcsave->fstack.flineno = funcstack->flineno + shfunc->lineno;
funcsave->fstack.prev = funcstack;
funcsave->fstack.tp = FS_FUNC;
funcstack = &funcsave->fstack;
- funcsave->fstack.flineno = shfunc->lineno;
funcsave->fstack.filename = getshfuncfile(shfunc);
prog = shfunc->funcdef;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author