Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113878 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6031 invoked from network); 31 Mar 2021 12:43:49 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 Mar 2021 12:43:49 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4B1851804D8 for ; Wed, 31 Mar 2021 05:41:18 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 31 Mar 2021 05:41:17 -0700 (PDT) Received: by mail-yb1-f182.google.com with SMTP id m132so21031650ybf.2 for ; Wed, 31 Mar 2021 05:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=o5WgkKzuW3KM0L6VHD7voPN5Eehwbiy03WUxrLQDq0k=; b=XmjM9uwGrARcwvK9uqxJrp2tqj9tFFGE23daudOaKq4Dci87aLQUI3WelFCMwKIHtl JnbmvkePjK1DHjyiD7y0Y5HI7uHockbKJDJy+VxlWkZVqcxn4JQ9W+3M8Z9esZfcGPcX nXIOoOCThVOPsvAgDreW3vGGmlleqrKaEUTv69r+k+0sAjbsEsn9QM7jc3ADharnLm0w hy7q+udxe28wPnAeHp3O8UcbjgvzfHTcWAOF7B1GvZrDhM4F8k9pXVwfhm0QTeNIqIjq jL+oqT99h/yK5psaJiUZ6aiZWbRgTkQ2/t47D23FSLUJo2yW22LUUNlyUlAnamliWVuq tiSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=o5WgkKzuW3KM0L6VHD7voPN5Eehwbiy03WUxrLQDq0k=; b=jEphbEhCx7OTztij+CN5iYSrCmEhYPbtY83PGDN/6MnVv+SxMQGA9GX8IT7UlVvfAW VOZyfaer+IV+C5Se27+Io7kCfl+yOwmD2J5qec3wtbTk/4gRFrbhdfJ4aL/oEgXl8qJx ZSuRrKlCXso23eCIX9xd4IzVE4id8bUv8tzBfp6wKzuislb7RWwHVNhkc6Wt/ZDmgG5m LYGM7ul23euQhymEzrrKoo6UPff1gdTRXNrVkhl5fGNAvhCoF4c7diNcre4PBYuokvPV iMYOQpneLqRlpOTM36/adY9F//UsH63Pxd9y9lwOIy9b24mmqLs6fdhE1oHJMwdSYh5T DH4w== X-Gm-Message-State: AOAM532ngC+++NAvsufcwrHs28yjqiZ0+DsoCSm0G5ZZFTaMI4D+Q7io 6hf2b3zffUn0cX42Y6sxTXmTBc/qKQtGTiHjZXTTCz9BavYH3g== X-Google-Smtp-Source: ABdhPJyoMZZx2RS4KDDf3AAy6XNZqWGmBQTpUZNEdS/WmWqiGlW6pYAXRRvXRrPiTgdtmOPYA+OuUM+aKtAIfZWtp0M= X-Received: by 2002:a25:db4c:: with SMTP id g73mr4159697ybf.2.1617194476925; Wed, 31 Mar 2021 05:41:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 31 Mar 2021 14:41:05 +0200 Message-ID: To: Internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [VOTE] noreturn type From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi internals On Wed, Mar 31, 2021 at 2:14 PM Andreas Hennings wrote: > > Also check my comment in the other thread: > If in the future we want a "bottom type" that also works for parameters > (generics or abstract methods), should we create a new keyword, or should > we attempt to find a keyword now that works for all cases? > Neither "never" nor "noreturn" seems suitable for use in parameters, but > "nothing" would be. While slightly misleading, noreturn absolutely could work as a parameter type, it's just not part of this RFC. I don't see why nothing would be more suitable than never. I do think noreturn/never in parameter types could potentially be useful as it would serve as static analysis information and a runtime check at the same time. https://stackoverflow.com/a/39419171/1320374 ``` function shouldNotHappen(never $never): void {} /** @param 1|2|3 $foo */ function foo($foo) { switch ($foo) { case 1: return 'One'; case 2: return 'Two'; } // Static analyzer can understand this value is not never but 3 // Throws a type error at runtime when reached as nothing can satisfy never shouldNotHappen($foo); } ``` Although it's worth noting that match doesn't have that problem as it throws implicitly on unhandled values. So maybe we should focus our efforts on making match usable with code blocks instead of just expressions. Ilija