Re: Re: RFC: Marking return values as important (#[\NoDiscard])

From: Date: Tue, 04 Mar 2025 22:08:36 +0000
Subject: Re: Re: RFC: Marking return values as important (#[\NoDiscard])
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-126564@lists.php.net to get a copy of this message
Hi Tim, On Tue, Mar 4, 2025, 22:16 Tim Düsterhus <tim@bastelstu.be> wrote: > Hi Marc > > Should the (void) cast not be accepted, we will only special > case the > assignment to $_ to not be elided, even if OPcache knows that > the > function will never return an object. The behavior for other variables > will remain unchanged. X Just asking, as my engine knowledge is a bit limited, Wouldn't it be possible that when OPcache would optimize away the unused variable assigned to a function, it could detect that that function have the NoDiscard attribute and also remove the attribute effect (warning triggering). Or identify that the function has the NoDiscard attribute and based on that do not optimize away the variable? -- Alex

« previous php.internals (#126564) next »