-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
Implement Safer D #17044
Implement Safer D #17044
Conversation
Thanks for your pull request, @WalterBright! Bugzilla referencesYour 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 locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#17044" |
4cf7a26
to
799283e
Compare
1d2ade0
to
b87d383
Compare
Finished the implementation. Turned out to be much less code than I anticipated. |
It doesn't need a spec PR because it's behind a |
bool isSaferD(FuncDeclaration fd) | ||
{ | ||
return fd.type.toTypeFunction().trust == TRUST.default_ && | ||
global.params.safer == FeatureState.enabled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this checking a scope flag rather than a global variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not wrong, but it would require more disruption as the flag isn't passed along. I suppose it would be alright for a future refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely be limited to newer editions, so it'll have to check it at the module level. Which eliminates the global flag.
This is a cool idea! It would also mean you can compile projects that depend on libraries that require |
DIP: https://github.com/WalterBright/documents/blob/38f0a846726b571f8108f6e63e5e217b91421c86/safer.md
This adds
-preview=safer
which enables safety checking on un-attributed functions. This just makes one check for starters.Newsgroup:
https://www.digitalmars.com/d/archives/digitalmars/dip/development/Safer_D_first_draft_387.html