Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113471 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70007 invoked from network); 11 Mar 2021 10:07:33 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Mar 2021 10:07:33 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2295E1804D3 for ; Thu, 11 Mar 2021 02:00:02 -0800 (PST) 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,HTML_MESSAGE, 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-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) (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 ; Thu, 11 Mar 2021 02:00:01 -0800 (PST) Received: by mail-io1-f52.google.com with SMTP id n14so21268188iog.3 for ; Thu, 11 Mar 2021 02:00:01 -0800 (PST) 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 :cc; bh=FmPih6V/P/0GFjfCFCqhJ2Qb19KarU1HDpuf/GMAHEg=; b=lZqnIT3Hx+xbcwgod42SHol8qAfcM0OYEnwnMUQYCJoDNcsEWvI8xsgXlaFgSkgs/9 T3TdJu+sK2SV7L6+v1l5jaG2jiqm8g+ge8dXZOvS6OivwRicn98yob4WUh8Xg2ntHNPm eOlDOWT6IbfjxCNxXWw4ky2HdMcsdMMwHovzabFgRpikKgOJhWbd4bNEjckJo5UU7Ekn XI5UIoGz14VyE4yp7gFgS5cfSeegxrVpNACs6MhKqxpY3A5xzsuMBadLXbJT9roJJhyC bDDml8Ztu1fSty+v1E2EI2S4AJD/EiIR2DT2U4s3B054pFSsyVuuHzZNcUvgu2aKU+qW o7Vg== 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:cc; bh=FmPih6V/P/0GFjfCFCqhJ2Qb19KarU1HDpuf/GMAHEg=; b=hFBNlQ0AsYoS9AQ0TqzoM9UL62/yhM0SOoTnaAaoasDiCaP7d2x466qHUmFPKeFDd1 FHe3omn5ym1wxya7craIp/E62ECpfucR05sYsulYA5m9hRKRlRTljNVlkZfZCVYicf9i suqSGbxPrrca9ocf1n2kxN6hycuxhVOe9DC2+ORRFnOZTPonSc5/5ZG3E0UzhRAUmlp6 7qJVWU01U6KQp4KtIvyO14obf6TuTAN0JlLWvyi51J9VhpNWF+GqTw2yP9M8+BTBfIs1 YaDNrmz+7Q2l4ijXefvy1WTzFKlhQ5UK6E9AzQnnuQ2YCaW7tYuzvWdrZE/OP4H/NRHI rJvw== X-Gm-Message-State: AOAM531APAI+ObWMe6y6hpM+AgZcHk0z4bfO6EwXDb22nd+9wn+QTR9e JbTlIhrk1cGK9DUgNqP/AfbEOpkpElxMFHqRQy4Rzv23FAlFyg== X-Google-Smtp-Source: ABdhPJxG3WZv8YwirIh8kF0B9sQb015uVIXUXLCD7LucQJfruqHgpcL+2w/9uSeVcGMVQQ4qz1/Fpe9IaF1y1VgNL4Q= X-Received: by 2002:a5e:dd09:: with SMTP id t9mr5429523iop.111.1615456800868; Thu, 11 Mar 2021 02:00:00 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 11 Mar 2021 10:59:49 +0100 Message-ID: To: Aleksander Machniak Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000c40f0805bd3fd8cf" Subject: Re: [PHP-DEV] [RFC] noreturn type From: ocramius@gmail.com (Marco Pivetta) --000000000000c40f0805bd3fd8cf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hey Aleksander, On Thu, Mar 11, 2021 at 8:25 AM Aleksander Machniak wrote: > On 10.03.2021 20:28, Ben Ramsey wrote: > >> I don't like that type covariance would be allowed. Why such an > >> exception to the rules? > > > > It=E2=80=99s not an exception. Returns are covariant. Parameters are > > contravariant. Since `noreturn` is a subtype of all other types, it > > behaves as expected. > > I see it's a subtype, I don't get why. Wouldn't it be better to be a > separate type so return type covariance is not allowed (as it is with > void)? Was it a design decision or a side product of the implementation? > `noreturn` is what's called the "bottom type", and it's a subtype of all types. It can sound counter-intuitive, but it is true that all methods in a subclass can be re-implemented with the bottom type as their return type (instead of their original one), and the system is still sound from a type perspective. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --000000000000c40f0805bd3fd8cf--