DIP: @mustuse as function return value annotation

mw mingwu at gmail.com
Mon Aug 12 08:09:33 UTC 2024


On Monday, 12 August 2024 at 06:02:20 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
> If I understand this correctly, you want the ``@mustuse`` 
> restriction to inherit upwards?

Yes. As said:

a) in both cases (@mustuse and @mustuse_remedy_legacy), this 
function property will be *transitive closure*, i.e. be 
propagated upwards and downwards, in all directions.


> This will not work due to the way D's compilation model works. 
> In a process not all compiler invocations will see this upward 
> inheritance.

I have no idea how the current D's compilation model works.

To implement what is proposed above, I assume there is only one 
global ASTree (singleton) of all the source files (even in the 
context of separate compilation of each D source file), which 
holds all the calculated annotation from different compilation 
passes, and the @mustuse checker is invoked after all the 
annotations are fully calculated.



More information about the dip.ideas mailing list