Skip to content

Conversation

@carblue
Copy link
Contributor

@carblue carblue commented Feb 20, 2018

Without this fix and
string relativePath(CaseSensitive cs = CaseSensitive.osDefault)
(string path, lazy string base = getcwd()) temporarily attributed @safe
the reported errors are:
std/path.d(1742): Error: scope variable result may not be returned
std/path.d(1748): Error: template instance std.path.buildNormalizedPath!char error instantiating
std/path.d(1800): while evaluating: static assert(buildNormalizedPath(["/foo/..", "/bar/./baz"][]) == "/bar/baz")
std/path.d(2873): Error: @safe function std.path.relativePath!cast(CaseSensitive)true.relativePath cannot call @System function std.conv.to!string.to!(ChooseResult!(ByCodeUnitImpl, Result)).to

Thus the remainder will be an error from std.conv.to!string.to only.

@dlang-bot dlang-bot added the Review:Trivial typos, formatting, comments label Feb 20, 2018
@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @carblue! 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.

Copy link
Contributor

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

LGTM

(FWIW this piece looks like it could use an appender)

std/path.d Outdated
result = chainPath(result, path).array;
else
result = path;
result = path.idup;
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about it: wouldn't assumeUnique be better here to avoid an unnecessary allocation?
I know the loop is already horrible with .array on every iteration, but that's not an argument to make it even worse?
To ensure that the new content is freshly allocated, we could check this after the loop is then and only idup then...

Copy link
Member

@MartinNowak MartinNowak left a comment

Choose a reason for hiding this comment

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

You need return scope or abbreviated (w/o ref) you can just use return on the paths parameter, as you're returning/escaping a parameter. Please file a bug report with the [scope] tag if something is fishy about variadic arguments. Just repainting the returned array can leak the passed in parameter without letting the compiler know.

@carblue
Copy link
Contributor Author

carblue commented Mar 7, 2018

I won't pursue this PR any more, just closing it

@carblue carblue closed this Mar 7, 2018
@carblue carblue deleted the dip1000_4 branch March 7, 2018 03:56
@carblue carblue restored the dip1000_4 branch March 19, 2018 05:33
@carblue carblue reopened this Mar 19, 2018
@WalterBright WalterBright added the Review:Vision Vision Plan https://wiki.dlang.org/Vision/2018H1 label Mar 22, 2018
@WalterBright
Copy link
Member

I redid this as #6357 but I don't see how this PR makes it any more DIP1000 compatible. The return value of the function is always copied into fresh memory.

@carblue carblue deleted the dip1000_4 branch March 28, 2018 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:Trivial typos, formatting, comments Review:Vision Vision Plan https://wiki.dlang.org/Vision/2018H1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants