dmd icon indicating copy to clipboard operation
dmd copied to clipboard

fix Issue 23260 - If constructors have a function body, they should i…

Open WalterBright opened this issue 3 years ago • 8 comments

…nfer attributes

This makes https://github.com/dlang/dmd/pull/14175 much more palatable.

WalterBright avatar Jul 21 '22 00:07 WalterBright

Thanks for your pull request, @WalterBright!

Bugzilla references

Auto-close Bugzilla Severity Description
23260 enhancement If constructors have a function body, they should infer attributes

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#14319"

dlang-bot avatar Jul 21 '22 00:07 dlang-bot

All kinds of problems are cropping up, like https://github.com/dlang/dmd/pull/14320

WalterBright avatar Jul 21 '22 02:07 WalterBright

What justifies that special case for ctors? And no, #14175 isn't a good reason.

kinke avatar Jul 21 '22 11:07 kinke

Wouldn't it be better to have attribute that says "Hey infer the system attributes for this function" without using templates? Adding edge cases like these just seemed to be asking for trouble.

12345swordy avatar Jul 21 '22 13:07 12345swordy

@kinke why isn't it a good reason? #14175 is a corruption opportunity specific to constructors.

WalterBright avatar Jul 22 '22 01:07 WalterBright

@kinke if you have a better idea on how to close the memory safety hole, I'm interested.

WalterBright avatar Jul 22 '22 01:07 WalterBright

if you have a better idea on how to close the memory safety hole, I'm interested.

https://github.com/dlang/dmd/pull/14175#discussion_r922852478

kinke avatar Jul 22 '22 13:07 kinke

@kinke replied in #14175

WalterBright avatar Jul 23 '22 03:07 WalterBright