Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add @saferSystem #20606

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Add @saferSystem #20606

wants to merge 1 commit into from

Conversation

0xEAB
Copy link
Member

@0xEAB 0xEAB commented Dec 26, 2024

Note

This would need a DIP.

I’m not really a fan of things only accessible through magic. This experiment adds a new attribute @saferSystem that allows users to explicitly enable “safer” checks for functions.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @0xEAB!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

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#20606"

@thewilsonator thewilsonator added Review:Pending DIP Approval Review:Needs Changelog A changelog entry needs to be added to /changelog labels Dec 26, 2024
@atilaneves
Copy link
Contributor

This would indeed need a DIP but at the very least an explanation of what this even does.

@thewilsonator thewilsonator added the Severity:safe @safe code label Dec 26, 2024
@0xEAB
Copy link
Member Author

0xEAB commented Dec 26, 2024

but at the very least an explanation of what this even does.

It adds an attribute for the behavior that is known as “safer”. That is means it enables the very same safety checks that are currently applied to functions with no safety annotation when -preview=safer is enabled.

@0xEAB
Copy link
Member Author

0xEAB commented Dec 26, 2024

A lot of the implementational bloat comes down to the addition of a new storage class. The way built-in attributes are implemented is that they are picked up into a storage class which gets later translated into a “trust” level. That trust level then determines the actual checks.

@0xEAB
Copy link
Member Author

0xEAB commented Dec 26, 2024

Also to clarify: This PR isn’t to be taken dead serious.

I was mostly interested in running this patch against the bigger testsuite and see how it interacts with the ecosystem world – you know, those tests performed by buildkite.

My point stands, I don’t like behavior that is only accessible through magic and cannot be reapplied after changing away from the defaults. I am aware that there’s this @default idea that we have up your sleeves that would also help eliminate said inconvenience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Review:Needs Changelog A changelog entry needs to be added to /changelog Review:Pending DIP Approval Severity:safe @safe code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants