Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93486 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 469 invoked from network); 24 May 2016 16:28:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 May 2016 16:28:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.46 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.46 mail-wm0-f46.google.com Received: from [74.125.82.46] ([74.125.82.46:36037] helo=mail-wm0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4D/A2-10476-E1184475 for ; Tue, 24 May 2016 12:28:14 -0400 Received: by mail-wm0-f46.google.com with SMTP id n129so139492908wmn.1 for ; Tue, 24 May 2016 09:28:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:from:to:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=YQEOjN3aHJdfswQI+I9PtrhtYd1J2zDW2CbMLwdV1uw=; b=XtsQn57kiSXzrkOmNAo+PRKI8N8sXIla+7pkJdVXBKZIrjTVYNbkaSV0Gv9TyUOtex Ps2HTJ+C5tN2Mf9ENzGdEyHgUlg22ql32+4sblXfn1kOH09fJ5vSuuV6ujfzGW4tY7fF qnc8gtr/x8aMCKqub6kDSxKfnBNyTHPTh3n1HsW/FEjz0GAMvtKFQlueJtKkEnTIAxiA yg0bwKOMBB5WU2nZZFKuvvOaePjQ2118OvUCoO57nXDQizyVy0Zfn97J+QT1X2FZtZgC d+DT4zbIoQg9KtLcomBZmthOqKuSc++hEIOkMmb0XIQxLUPNcuQbEtbFypxcupvGruVZ dGXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:references:from:to:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=YQEOjN3aHJdfswQI+I9PtrhtYd1J2zDW2CbMLwdV1uw=; b=MXwCmrGTNWSkVopGQoV6cJGnjapQB0gxqCacOhDnw+3/LS7lHARa5m+gWaOlzxm5D5 ADEjlOzn7/rOS8r6i8nydcMexiiC//0g8yF5sEdHWAJjOSEt9y/JG4ceSccBsoXat2GM S/fN8co88tJFmvhfaT/+xp1KyQ7StL3DcBur3VHX6dhY7St7C0/hdTAGuH4Tr9+HJSgV ghXtYd6CqkaBYgISAvVpD31XSJfhR9b9HvsLGSjYfQxcCSZcoqurB2OAY+VTd1Q5ah7K qfZksrW4FDLy7eOXiEBMuc2QZCbyirzgnfpPZM0ohyXvfXfYjhyPezvSSLi9HXg2lKhT 9wjw== X-Gm-Message-State: ALyK8tIaBGw9hQgBoBvX6nyLr4MIpH4pCKC1g0JJQfeIHv4KgCCfzoJCyf8OkWwgVg7EIg== X-Received: by 10.194.231.169 with SMTP id th9mr5864182wjc.32.1464107290989; Tue, 24 May 2016 09:28:10 -0700 (PDT) Received: from [192.168.0.98] ([93.188.182.58]) by smtp.gmail.com with ESMTPSA id o76sm4587352wme.0.2016.05.24.09.28.09 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 May 2016 09:28:10 -0700 (PDT) References: <72f547d6-5fcf-3cd2-960d-cb612a429e47@php.net> To: PHP internals Message-ID: <894687cd-38fa-da3d-2515-4df085091976@gmail.com> Date: Tue, 24 May 2016 17:26:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Exception::getLine() From: rowan.collins@gmail.com (Rowan Collins) On 24/05/2016 16:32, Rasmus Schultz wrote: > The second use-case (indirect throw, factory) and third use-case > (re-throwing) are both broken as-is - in either case, it isn't > reporting the correct stack-trace now. This change corrects those > cases. Even if that's a minor BC break, it corrects an error. I'm still not convinced that re-throwing should automatically generate a new stack trace. To repeat my previous question, why should the two blocks below produce different backtraces? # A: try { throw new FooException; } catch ( BarException $e ) { // FooException doesn't match the constraint, so bubbles up } # B: try { throw new FooException; } catch ( Exception $e ) { if ( ! $e instanceOf BarException ) { // FooException doesn't match the constraint, so is re-thrown throw $e; } } Since no actual changes happened to $e in block B (and exceptions should normally be immutable in practice, I think), what information is gained by knowing that a block caught it, examined it, and decided it could do nothing with it? And if that information is valuable, why is not also valuable when the check is implicit in the specification of the catch clause? In my opinion, it would be reasonable to attach the stack trace *the first time* an exception was thrown. This fixes your main problem, indirect / factory construction, and would be relatively simple to implement - when throwing the exception, check if the stack trace has already been added; if not, add it. > Would a change like this require an RFC (and a vote) or is it arguably > a bug? (I'm guessing this change is too substantial to be considered a > "bug fix"?) In my opinion, it's substantial behaviour change, and would definitely require an RFC, particularly if the default behaviour of one or more methods would change, so that unchanged PHP code gave different results. Regards, -- Rowan Collins [IMSoP]