Skip to content

Conversation

@WalterBright
Copy link
Member

…arameter

Very similar to fix for #14363

@dlang-bot
Copy link
Contributor

dlang-bot commented Aug 12, 2022

Thanks for your pull request, @WalterBright!

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

Comment on lines +16 to +19
DG forwardDg(ref int c)
{
return () {assert(c == 42);};
}
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the compiler infer the closure to be scope in this case ?
Regardless if it does/can infer it currently, we should not have this error for scope delegate, should we ?

Copy link
Member Author

Choose a reason for hiding this comment

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

ref parameters are implicitly pointers, and are automatically not allowed to escape the function. No need for scope.

The trouble here is the delegate escapes the function, thereby escaping the reference to c.

Copy link
Member

Choose a reason for hiding this comment

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

Right, we're returning the delegate. Can we add a test that not escaping the delegate (the delegate being scope) does not trigger error ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The error is triggered when the delegate is tested to see if a dynamic closure is being created. So the tests for @nogc already do this.

@WalterBright
Copy link
Member Author

Blocked by dlang/phobos#8530

@WalterBright
Copy link
Member Author

I guess the test suite is going to drip-drip-drip the phobos failings one at a time.

@WalterBright
Copy link
Member Author

Blocked by bugs in Buildkite projects.

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

Projects

No open projects
Status: In Progress

Development

Successfully merging this pull request may close these issues.

5 participants