Skip to content

Disables Typedef.toString()#6217

Closed
denizzzka wants to merge 3 commits intodlang:masterfrom
denizzzka:master
Closed

Disables Typedef.toString()#6217
denizzzka wants to merge 3 commits intodlang:masterfrom
denizzzka:master

Conversation

@denizzzka
Copy link
Contributor

It is need to avoid silently conversion of Typedef struct to string by std.conv.to and to prohibit string type payload leakage.

Discussion:
https://forum.dlang.org/post/kjzayldqnixehfprgslc@forum.dlang.org

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @denizzzka! 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 annotated coverage diff directly on GitHub with CodeCov's browser extension
  • 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.

@MetaLang
Copy link
Member

Sorry, I think I caused a misunderstanding. We do not want to add an @disable'd toString method for Typedef, but add a toString method that just delegates to the wrapped value.

Check out std.typecons.Nullable's various overloads for inspiration:
https://github.com/dlang/phobos/blob/master/std/typecons.d#L2458

@denizzzka
Copy link
Contributor Author

denizzzka commented Feb 23, 2018

but add a toString method that just delegates to the wrapped value.

But this will make an exception for wrapped string types - it will be converted by conv.to!string unintentionally

@denizzzka
Copy link
Contributor Author

denizzzka commented Feb 23, 2018

@MetaLang You are right. Calling conv.to function is always a conscious action, and an unnoticed leak of a string isn't possible here.

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