develooper Front page | perl.perl5.porters | Postings from June 2018

Re: [perl #133239] Very misleading line number for warnings in somecases

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
June 20, 2018 11:28
Subject:
Re: [perl #133239] Very misleading line number for warnings in somecases
Message ID:
20180620112836.GN2753@iabyn.com
On Wed, Jun 20, 2018 at 06:15:25AM -0400, Rocky Bernstein wrote:
> Apparently, I wasn't clear in describing what I was proposing. There were
> two parts to what I wrote:
> 
> 
>    1. A suggstion to add some sort of mechanism whereby a user can write a
>    custom error/warning handler, and then
>    2. a suggestiion on how to use this to provide a better error location
>    indication
> 
> Let me elaborate a little on 1.
> 
> Currently Perl has an END block which is close, but has a couple of
> problems here.

I don't understand what END blocks have to do with this.

On the other hand, the pre-existing $SIG{__WARN__} and $SIG{__DIE__} sound
close to what you want. The main issue seems that the value of PL_op is
not available at the time the handler is called, even if the handler is an
XS sub  (PL_op gets saved, then set to a faked up OP_ENTERSUB for the
purposes of calling the handler).

Perhaps perl should set an interpreter variable, PL_warn_err_op, say, before
calling the warn/die hook?

PS I'm assuming you're not suggesting that perl itself does (2)?

-- 
This email is confidential, and now that you have read it you are legally
obliged to shoot yourself. Or shoot a lawyer, if you prefer. If you have
received this email in error, place it in its original wrapping and return
for a full refund. By opening this email, you accept that Elvis lives.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About