Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94893 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60327 invoked from network); 7 Aug 2016 08:27:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Aug 2016 08:27:23 -0000 Authentication-Results: pb1.pair.com header.from=me@daveyshafik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@daveyshafik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain daveyshafik.com from 209.85.220.174 cause and error) X-PHP-List-Original-Sender: me@daveyshafik.com X-Host-Fingerprint: 209.85.220.174 mail-qk0-f174.google.com Received: from [209.85.220.174] ([209.85.220.174:35508] helo=mail-qk0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4B/5F-33134-AE0F6A75 for ; Sun, 07 Aug 2016 04:27:22 -0400 Received: by mail-qk0-f174.google.com with SMTP id x185so105713276qkc.2 for ; Sun, 07 Aug 2016 01:27:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daveyshafik-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=jtd91RLSm8ESWoOc6kFN/xvdQiAn3Oyrmbqid3rj60g=; b=nefkzy8ZzjuLZ8yJtpScZMl0pXNtJ3fNnQ+DziVtVf7gFYHvyVp9FTxgqV/yGkyvNH Iuid9HQGl1GXfw49RnfYNaW6nW3k+2T8oZVNKZkfD9mtVyuz+lugQ3Tbiy8tbJxeljLY BlDglprSX8rBYbNFvVPFkK79Td4NPqvn8r2IR2drIEUVJ3ZGNViOdHiCzEUepEFrrdZj +KOn2TuucjMsQPNtG3xavezf7zz4SxykMNKKr1tk3iLqKXXqUAUlZ+BN8tDchiSwe45C sanAVt/ep8fJTpzACk+Zg3lolG+HSP3f/d+NKQcdZLtIFfQcpLCrLR/q4gP0SRbh7KEW E5Yg== 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=jtd91RLSm8ESWoOc6kFN/xvdQiAn3Oyrmbqid3rj60g=; b=RgZ79Eno40So4KYjerjzACWo/+XJEQPFDnE11y9vdLHtxrzpfeL8ZZJYzyqA5LK1RD 6FAoKEb+dI327WqJnwvR9fDc0bx8uwfvZGU9WEuwaT7cpYlfF9fld4FjwS+kfDcOE+ZF XXyxr6Vd5+MYZ6pzQCGMWJ4Npk7RO8FmTxP8i4FYuw9ZHaoyvuCwi/k+TfaDr4lr7+Sy GQu38rCDxP6LaVrEdWEy0iCikojL0n9dOKhtGj5b1Gh2BLueLwhCoT6HW21vcb6ZhCjI luV2NIWJzK3Cjdyy98ePunejbySA3UGy6DhDFkgWhYcLUY0YRYiWjDU3l6Satm0as0oT WPlw== X-Gm-Message-State: AEkoouteiZ0VuMde6s6cZpBoGmluoX+FtimE/1CiZIM2uVLcBgFxzR4wJkmAbn+CboTp0BUtsGjfnADxBUWauuf/ X-Received: by 10.55.185.131 with SMTP id j125mr20938331qkf.138.1470558439499; Sun, 07 Aug 2016 01:27:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.237.55.138 with HTTP; Sun, 7 Aug 2016 01:27:18 -0700 (PDT) In-Reply-To: References: Date: Sun, 7 Aug 2016 01:27:18 -0700 Message-ID: To: Nikita Popov Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=94eb2c0490786880bc0539771108 Subject: Re: [PHP-DEV] Undocumented Nullable Return Behavior From: me@daveyshafik.com (Davey Shafik) --94eb2c0490786880bc0539771108 Content-Type: text/plain; charset=UTF-8 Nikita, Just to confirm for explicitness-sake: > Nullable return types work inversely to void return types. You must return either the specified type, or an explicit null. Anything else is either a TypeError (incorrect type [implicitly] returned), or a [compile time] fatal error (return without value). Is it worthwhile updating the RFC with this information and examples as it is most likely what will be used to create documentation (if it's not been documented already) and the spec. I'm happy to do that, if that's desired. - Davey On Sun, Aug 7, 2016 at 12:58 AM, Nikita Popov wrote: > 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 >> > > --94eb2c0490786880bc0539771108--