Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94892 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58175 invoked from network); 7 Aug 2016 07:58:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Aug 2016 07:58:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.177 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.161.177 mail-yw0-f177.google.com Received: from [209.85.161.177] ([209.85.161.177:33797] helo=mail-yw0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1B/FE-33134-42AE6A75 for ; Sun, 07 Aug 2016 03:58:29 -0400 Received: by mail-yw0-f177.google.com with SMTP id z8so289472444ywa.1 for ; Sun, 07 Aug 2016 00:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Z6M5QSMrdttKQaHhuYmKopmpRkkPkkrIWZ7OnjD/EpU=; b=ypD6ZRPnwzW/xzS33+zUrD+Ytfe9FBPLWLIpotrVgU4xPx4V5Kajh5970e9E5/w+Js 0+2FCjoluXV+A4obMOOET1pY9xGSwsn3emCuXSEx2ezJ6L69IJ7Z9k7JgAq7YbX0MCRd XUZA7rlSm3orGpcZMz6F7GBFSxEk0hxsXnAv3cnxJQwFFbFY2GhdE2NsDQYJS3SN3bRK qoFFtQGeefV+BmUrivgf8XVdpi0/DqLVjrbfLWu5eoSV/XqgJy9LHGOhHxk3psIgERn1 6HHmVrj48iWRAq2qEXik2nlS339lx1KNmYtwIZg971U3ZngbKt2claVPMUwSc0bcaNVX eKDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Z6M5QSMrdttKQaHhuYmKopmpRkkPkkrIWZ7OnjD/EpU=; b=h38C49EfyX5NdIkcrcI8lgkRjeQIYjx7ppJ5tItZb99sOnMr9NrXlgumVBA05MMX/F s5IqdzgscrGrRI/prd7oJ/Ye4TeERYWkzNj/eOjhZp4QC5CprVSeogQHZ3Dk8hC+CM1j YynelUDbSV+FB8SkZXJB1YJhwTubQRc8Hv3Me5r2POH+8r8nT2VlpZ7Hcc2RP/diQ1EA FSQdRA5j6/6Q1Gd7y99zvvlgnFWwFKA5e8C+GB8snuN0jKQr1nwG8qe0u0HBReDBjGI6 jjnIEYMC9aneRsfx9XFCYGtsGyJi4bQHAdEXUso3Yx1DFjZ2aSH9eIEJsyQwjNzgugsh yVNg== X-Gm-Message-State: AEkoouuKObBqELviTsjzEBPl0hqTtkxphj6PlB3CvgVDpOJUrADqKDnEQw4cEX4fCOZ2eLaLadG8wpyhQYstAQ== X-Received: by 10.13.254.135 with SMTP id o129mr57492979ywf.117.1470556705098; Sun, 07 Aug 2016 00:58:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.131.129 with HTTP; Sun, 7 Aug 2016 00:58:24 -0700 (PDT) In-Reply-To: References: Date: Sun, 7 Aug 2016 09:58:24 +0200 Message-ID: To: Davey Shafik Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=94eb2c07e31e0791cf053976aa96 Subject: Re: [PHP-DEV] Undocumented Nullable Return Behavior From: nikita.ppv@gmail.com (Nikita Popov) --94eb2c07e31e0791cf053976aa96 Content-Type: text/plain; charset=UTF-8 On Sun, Aug 7, 2016 at 9:07 AM, Davey Shafik wrote: > Hi internals, > > In the nullable types we do not allow implicit return null/return with no > value to fulfill a nullable type. > > - No return will result in a TypeError when executed > - Return with no value will be an actual fatal error, which I believe is > due to the fact it's not found at runtime, should be a TypeError or > ParseError if possible? > It's a compile time error. Compile time errors are currently fatal errors for technical reasons. > - Return explicit null is fine (as expected) > > See: https://3v4l.org/h6IYF > > I believe the first two are contrary to PHP's "null is always returned if > nothing else is". > > OTOH, it makes sense as it's the entire reasoning behind return void vs > return null. > Indeed. The current behavior is consistent with the (explicit decision from) the void RFC. Additionally, the current behavior is consistent with the behavior of the implementation at the time the RFC was voted, with the only difference that I have made this a compile-time error after the fact (because I think if we know that something will always result in a runtime error, we should try to detect it at compile-time already, and because the void error is detected at compile-time as well). Nikita > This behavior is completely undocumented in the RFC. > > It's definitely something we should make an explicit decision on for the > language spec if nothing else. > > We should also make any decisions on this prior to beta3 in < 2 weeks. > > Thoughts? > > - Davey > --94eb2c07e31e0791cf053976aa96--