Skip to content

Fix #18670 - Default arguments bypass most attribute checks#22908

Draft
dkorpel wants to merge 2 commits intodlang:masterfrom
dkorpel:defaultarg-attributes
Draft

Fix #18670 - Default arguments bypass most attribute checks#22908
dkorpel wants to merge 2 commits intodlang:masterfrom
dkorpel:defaultarg-attributes

Conversation

@dkorpel
Copy link
Copy Markdown
Contributor

@dkorpel dkorpel commented Apr 10, 2026

No description provided.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

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.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

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

Comment on lines +3314 to +3319
.deprecation(loc, "`pure` %s `%s` accessing mutable static data `%s` in default argument",
sc.func.kind(), sc.func.toPrettyChars(), v.toErrMsg());
else
{
error(loc, "`pure` %s `%s` cannot access mutable static data `%s`",
sc.func.kind(), sc.func.toPrettyChars(), v.toErrMsg());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason not to use previewErrorFunc here?

{
if (useDeprecation)
{
.deprecation(loc, "`pure` %s `%s` calling impure %s `%s` in default argument",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment on lines +3110 to +3111
if (!f.isDtorDeclaration())
errorSupplementalInferredAttr(f, /*max depth*/ 10, /*deprecation*/ false, STC.pure_, global.errorSink);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the supplemental not printed for a deprecation?

if (useDeprecation)
{
// Introduced in 2.113
.deprecation(loc, "`@safe` %s `%s` calling `@system` %s `%s` in default argument",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants