-
-
Notifications
You must be signed in to change notification settings - Fork 747
std.uni: add some scope and return #6212
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
Conversation
|
Thanks for your pull request, @WalterBright! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
89e1b37 to
fb86320
Compare
|
Curiously, that doesn't add the same scope and return annotations. |
|
The circleci failure appears bogus. |
|
Well, about 3 weeks ago I had - IIRC - the same impure errors with circleci and #6041 and could reproduce them with either make -f posix.mak std/uni.test or make -j6 -f posix.mak publictests. I don't recall exactly the route I took to get rid of them (GcPolicy.destroy pure, ForwardStrings.fwdStr @trusted being essential parts of the fix). In the end, for a good D-style, I removed all (/most of?) inferred attributes/storage class where I ever touched signatures. The posix.mak I used locally is in #6195. Another difficulty was, to have the std.uni code compile with both, either -dip25 or -dip1000. |
MartinNowak
left a 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.
Quite a lot of @trusted around here.
| bool match(C)(ref C[] str) scope const pure @trusted | ||
| if (isSomeChar!C) | ||
| { | ||
| return fwdStr!"match"(str); |
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.
How about marking the mixed in fwdStr method as @safe/trusted and scope instead, then you could rely on inference and also remove the @trusted.
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.
It's a good idea, but I am only concerned here with adding scope and return annotations.
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 was mostly asking because it's hard to seen whether fwdStr really does not escape anything, and adding scope to a @trusted function is unfortunately unchecked by the compiler.
Yes you can even use Why? It was initially intended to ensure that all examples are runnable on dlang.org, but it's also an extra safety net against privacy issues and in your case, this user code would now stop to work: void main()
{
import std.datetime.interval;
import std.datetime.date : Date, DayOfWeek;
auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
auto func = everyDayOfWeek!Date(DayOfWeek.mon);
auto range = interval.fwdRange(func);
}(simplified from the extracted public unittests) |
DmitryOlshansky
left a 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.
The change is fine and compiler should be able to fix some unsafety I was concerned about.
|
Errors seems about right |
It's also unclear why it would pass the unittests on the autotester and fail them on CircleCI. |
fb86320 to
3dec925
Compare
Because the autotester just runs In short, void main()
{
import std.datetime.interval;
import std.datetime.date : Date, DayOfWeek;
auto interval = Interval!Date(Date(2010, 9, 2), Date(2010, 9, 27));
auto func = everyDayOfWeek!Date(DayOfWeek.mon);
auto range = interval.fwdRange(func);
} |
3dec925 to
eae1520
Compare
|
So, I deleted all the |
There's no obvious use of std.uni there. |
|
fwdStr just seems to be an awful piece of code. The worst is, it does unsafe things, which prevents the compiler from checking it as @MartinNowak pointed out. |
|
I'm going to go with #6041 and just abandon this. |
No description provided.