Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] Anonymous functions cause funcfiletrace to produce function-relative line numbers

On 11 Dec 2017, at 04:12, Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> Oops, try this instead.

This one does not seem to have been entirely successful.

The reason i encountered this is that i was playing with a 'panic' function that
prints a trace-back. Here's a test script that replicates the basic 'stack' i
had going before:

  panic() {
    print -rC2 -- $functrace $funcfiletrace
    exit 1
  puts() {
  main() {
    () { puts }

The output, after applying the patch:

  puts:1            tracetest.zsh:15
  (anon):0          tracetest.zsh:9
  main:1            tracetest.zsh:9
  tracetest.zsh:11  tracetest.zsh:11

The line number for the (anon) call is correct now, but the one for the puts
call is wrong — there aren't even 15 lines in the script.

With my real-world code that line number seemed to be the sum of the current
function-relative number and the previous file-absolute number. That isn't the
case in this example, but maybe it had something to do with the fact that my
functions were all in separate files, unlike the ones here. Or it could be a
coincidence i guess.


Messages sorted by: Reverse Date, Date, Thread, Author