-
-
Notifications
You must be signed in to change notification settings - Fork 745
Annotate more of phobos with return
and scope
#8113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1953,7 +1953,7 @@ private enum bool hasCheapIteration(R) = isArray!R; | |
See_Also: | ||
For a lazy version, see $(REF joiner, std,algorithm,iteration) | ||
+/ | ||
ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, scope R sep) | ||
ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, R sep) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this removes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Range functions should ideally infer
So the long term fix is to ensure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this break existing code if the inference fails? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the accepts-invalid fixes for dip1000 are breaking changes. Luckily dip1000 is still experimental. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But these changes are neither specific to DIP1000 nor about actually invalid code. It would be better to first improve the inference s.t. there is no unecessary breakage. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What code do you think would break without There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have aspecific example ATM, will post one if I find a small example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dlang/dmd#12010 is going to break such dip1000 code in the wild undoubtedly, I just tested it on my own 37 KLOC dip1000 library and I had to add 3 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neither said nor implied that - some breakage will be unavoidable. I'm just concerned that these changes introduce a temporary regression that could be avoided by first improving the But the actual fallout might be neglegible given that your projects required minimal changes and buildkite passes as is. |
||
if (isInputRange!RoR && | ||
isInputRange!(Unqual!(ElementType!RoR)) && | ||
isInputRange!R && | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -558,14 +558,14 @@ if (isRandomAccessRange!R && hasSlicing!R && isSomeChar!(ElementType!R) || isNar | |
the POSIX requirements for the 'dirname' shell utility) | ||
(with suitable adaptations for Windows paths). | ||
*/ | ||
auto dirName(R)(R path) | ||
auto dirName(R)(return scope R path) | ||
if (isRandomAccessRange!R && hasSlicing!R && hasLength!R && isSomeChar!(ElementType!R) && !isSomeString!R) | ||
{ | ||
return _dirName(path); | ||
} | ||
|
||
/// ditto | ||
auto dirName(C)(C[] path) | ||
auto dirName(C)(return scope C[] path) | ||
if (isSomeChar!C) | ||
{ | ||
return _dirName(path); | ||
|
@@ -662,7 +662,7 @@ if (isSomeChar!C) | |
//static assert(dirName("dir/file".byChar).array == "dir"); | ||
} | ||
|
||
private auto _dirName(R)(R path) | ||
private auto _dirName(R)(return scope R path) | ||
{ | ||
static auto result(bool dot, typeof(path[0 .. 1]) p) | ||
{ | ||
|
@@ -1448,7 +1448,7 @@ private auto _withDefaultExtension(R, C)(R path, C[] ext) | |
Returns: The assembled path. | ||
*/ | ||
immutable(ElementEncodingType!(ElementType!Range))[] | ||
buildPath(Range)(Range segments) | ||
buildPath(Range)(scope Range segments) | ||
if (isInputRange!Range && !isInfinite!Range && isSomeString!(ElementType!Range)) | ||
{ | ||
if (segments.empty) return null; | ||
|
@@ -2747,7 +2747,7 @@ else version (Posix) | |
See_Also: | ||
$(LREF asAbsolutePath) which does not allocate | ||
*/ | ||
string absolutePath(return scope string path, lazy string base = getcwd()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
string absolutePath(string path, lazy string base = getcwd()) | ||
@safe pure | ||
{ | ||
import std.array : array; | ||
|
@@ -2893,7 +2893,7 @@ if (isConvertibleToString!R) | |
`Exception` if the specified _base directory is not absolute. | ||
*/ | ||
string relativePath(CaseSensitive cs = CaseSensitive.osDefault) | ||
(scope return string path, lazy string base = getcwd()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
(string path, lazy string base = getcwd()) | ||
{ | ||
if (!isAbsolute(path)) | ||
return path; | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the reversion of parameter order?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dlang/druntime#3480 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably should have made a comment in the source code as well