Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113620 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 90634 invoked from network); 19 Mar 2021 15:54:39 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Mar 2021 15:54:39 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1BD8D180504 for ; Fri, 19 Mar 2021 08:49:12 -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,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-vk1-f178.google.com (mail-vk1-f178.google.com [209.85.221.178]) (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 ; Fri, 19 Mar 2021 08:49:11 -0700 (PDT) Received: by mail-vk1-f178.google.com with SMTP id s136so2204438vks.4 for ; Fri, 19 Mar 2021 08:49:11 -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 :cc; bh=vm1lgaPGCJrcqgSfPpFebryGyfp3ihG60zWnrJjcczY=; b=Iz9ZMRqFc2lZ7vr99plO3pWlGtNckTSXXlpBYV3kkSxxFtwXtRlDsk5ldELTUTwa2Q wG7xmeD0PveXQOUltcucBVCMgCQdZlQojiBdiHS1GTEAXmXqxUHHlaAekc9tH/pQa70w 9v++57h2HxyBBU1OBojXo4ABkE+pK9ZbJr2ouHLpR8P+9TopnSe7QedEjlsUnhaK48rQ Ed3oDHPR5OyR6X9TBupSON2cLwN9oDLoWBXyKjYQ483n4FAUHEqay8mI1U1ilG5nLAoX irTjS4EYWM4ciU+3j2Tuzy9I53Y4HF2rsIa5kQdjLTE0TY0azeZf1MGCA9yoy+gmNuES P9RA== 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=vm1lgaPGCJrcqgSfPpFebryGyfp3ihG60zWnrJjcczY=; b=OJmkr40W37tj9HtwpFmJbn1dXuhybKi3iHj+kReU7aCh6yL/dXcjeYnIXtNV2tbhIp q4Ibh4AAKnYJj9Z1FhE+PPQr/i0PYhMrIwPzkoybWaWFT37uch4Ek2iXTBQeq6NxB62c 39ofip2a/s/Quwfb+0ywZX1HwOAz/zUgmRpidRj3TciMNAbvATXZJTyZQeCRgVCJL67u OypDzyXgqAS+JiqGjao8IAulQx7MRwoavpc3ckEj0M682ZZ6eE//QbscwhW3c/ysCStm mCUWv+BfvV8muAOEBG7IYFTVpwuaaJztYX4aASlIkdi0J+hs0crdbeweJN/0/iH9eY85 IcKw== X-Gm-Message-State: AOAM531baFgGJMcG5MeYRGUE7cSsXHJPsLjvJQyLPnpK8moaeuw7oGuO cwmj5WihmvVR56wLVDNQiLCYUyZJZCK3QaFH2Cw= X-Google-Smtp-Source: ABdhPJynVq79ky6cvsTOV6X0sDkH0dsPujjwbqTufnrp5+yMjnEv+UWUNcOucnrpX33VMD+DTeNOicCWkXueoXE54WE= X-Received: by 2002:a1f:a8ce:: with SMTP id r197mr1749358vke.16.1616168949349; Fri, 19 Mar 2021 08:49:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 19 Mar 2021 11:48:58 -0400 Message-ID: To: Nikita Popov Cc: Marco Pivetta , Internals Content-Type: multipart/alternative; boundary="0000000000001f822405bde5a82b" Subject: Re: [PHP-DEV] [RFC] noreturn type From: matthewmatthew@gmail.com (Matthew Brown) --0000000000001f822405bde5a82b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 19 Mar 2021 at 10:53, Nikita Popov wrote: > On Fri, Mar 19, 2021 at 3:45 PM Marco Pivetta wrote: > >> Hey Nikita, >> >> On Fri, Mar 19, 2021, 14:35 Nikita Popov wrote: >> >>> >>> Is it allowed to declare a noreturn function that returns by reference? >>> >>> function &foo(): noreturn {} >>> >> >> Given that `noreturn` means it should throw, loop forever or exit, how >> would a by-ref usage be applied/useful? >> >> Or is it a hint at a missing test? >> > > Mainly a hint for missing spec ;) > > Context is that we're considering to deprecate by-ref void return ( > https://wiki.php.net/rfc/deprecations_php_8_1#return_by_reference_with_vo= id_type), > so it would make sense to me to prohibit this for noreturn from the start= . > > However, I could also see an argument for why allowing it may be useful > due to variance considerations. It would allow you to write something lik= e > this: > > class A { > public function &test(): int { ... } > } > class B extends A { > public function &test(): noreturn { throw new Exception; } > } > > While dropping the by-ref return on B::test() would be forbidden by > variance (and I don't think we'd want to add more special rules here, lik= e > ignoring ref-return variance for noreturn functions). > > Regards, > Nikita > I think it should be allowed due to the variance considerations =E2=80=93 I= 've updated the RFC to include your example. --0000000000001f822405bde5a82b--