Skip to content

std.digest: remove wrong use of scope#4549

Merged
andralex merged 1 commit intodlang:masterfrom
WalterBright:scopedigest
Jul 3, 2016
Merged

std.digest: remove wrong use of scope#4549
andralex merged 1 commit intodlang:masterfrom
WalterBright:scopedigest

Conversation

@WalterBright
Copy link
Member

Returning scope variables doesn't work. This is a blocker for dlang/dmd#5903

* This is a convenience function to calculate the hash of a value using the OOP API.
*/
final @trusted nothrow ubyte[] digest(scope const(void[])[] data...)
final @trusted nothrow ubyte[] digest(const(void[])[] data...)
Copy link
Contributor

Choose a reason for hiding this comment

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

This one doesn't look wrong. It calls put on the individual void[]s. put's parameter is scope, so it guarantees not to escape the void[]. finish can't have a reference into data then which it could escape.

This hinges on put's scope being correct, I guess.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's wrong because the implementation is returning its argument. It's exactly the sort of thing scope does not allow.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's wrong because the implementation is returning its argument.

But it doesn't. It returns this.finish().

Copy link
Contributor

Choose a reason for hiding this comment

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

I've made a PR to revert this line as I think this was a mistake. #4552

@andralex andralex merged commit 3e9367a into dlang:master Jul 3, 2016
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