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
Enable -checkaction=context by default #11925
base: master
Are you sure you want to change the base?
Conversation
Running it on my machine yields an ICE on some tests:
Also a deprecation triggering here and there:
|
Those should already work, could you provide an example that fails? There's also another problem with DIP1000 flagging the hidden temporaries created by |
The backend assertion failures seems to be related to the inliner creating a really weird AST: Test case (which passes without // REQUIRED_ARGS: -checkaction=context -inline
struct S
{
S get()() const { return this; }
}
auto f(S s) { return s; }
void main()
{
auto s = S();
assert(f(s.get) == s);
} AST without void main()
{
S s = S();
assert(f(s.get()) is s, _d_assert_fail(f(s.get()), s));
return 0;
} With void main()
{
S s = S();
assert(((S s = s;) , (s)) is s, ((const(S) a = (S s = s;) , (s);) , ((ref const(S) b = s;)) , ((string valA = (ref const(S) t = a;) , (alias miniT = pure nothrow @safe string miniFormat(ref const(S) v)
{
import core.internal.traits : isAggregateType;
import core.stdc.stdio : sprintf;
import core.stdc.string : strlen;
string msg = "S(";
/*unrolled*/ {
}
msg ~= ")";
return msg;
}
;
, (*((string function(ref const(S)) pure nothrow @safe t = & miniFormat;) , (alias RT = string;
, (alias P = (ref const(S));
) , (alias type = string function(ref const(S)) pure nothrow @nogc @safe;
) , cast(string function(ref const(S)) pure nothrow @nogc @safe)t)))(t));) , ((string valB = (ref const(S) t = b;) , (alias miniT = pure nothrow @safe string miniFormat(ref const(S) v)
{
import core.internal.traits : isAggregateType;
import core.stdc.stdio : sprintf;
import core.stdc.string : strlen;
string msg = "S(";
/*unrolled*/ {
}
msg ~= ")";
return msg;
}
;
, (*((string function(ref const(S)) pure nothrow @safe t = & miniFormat;) , (alias RT = string;
, (alias P = (ref const(S));
) , (alias type = string function(ref const(S)) pure nothrow @nogc @safe;
) , cast(string function(ref const(S)) pure nothrow @nogc @safe)t)))(t));)) , ((enum string token = "!=";)) , combine(valA, "!=", valB))));
return 0;
} Or is that just |
Each of these failures needs to be posted to bugzilla. |
It fails on tupleof. #11987 will help with debugging. |
|
|
@Geod24 would fixing those 2 issues make this PR green? |
Hopefully. I don't know what's causing the backend issue and have no plan to look into it in the foreseeable future. However @MoonlightSentinel and I did look into the tuple ones, and he submitted a couple draft PRs, so I have good hope this one will be fixed soon-ish. |
e8fcbef
to
b191a41
Compare
Rebased on master, let's see how this fare. |
@MoonlightSentinel : Looks like the fix for tuple was incomplete:
Code in question: void test10178()
{
struct S { static int count; }
S s;
assert((s.tupleof == s.tupleof) == true);
assert((s.tupleof != s.tupleof) == false);
S getS()
{
S s;
++S.count;
return s;
}
assert(getS().tupleof == getS().tupleof); // L1473
assert(S.count == 2);
}
void test10004()
{
static int count = 0;
static S make(S)()
{
++count; // necessary to make this function impure
S s;
return s;
}
struct SX(T...) {
T field; alias field this;
}
alias S = SX!(int, long);
assert(make!S.field == make!S.field); // L1541
assert(count == 2);
} |
And it trips on the following code: assert(( boo(4) = 2) == 2); assert(( maz(4) = 2) == 2);
assert((4.boo = 2) == 2); assert((4.maz = 2) == 2);
assert(( coo(a) = 2) == 2); assert(( maz(a) = 2) == 2);
assert((a.coo = 2) == 2); assert((a.maz = 2) == 2);
assert(( mar(s) = 2) == 2); assert(( maz(s) = 2) == 2);
assert((s.mar = 2) == 2); assert((s.maz = 2) == 2); |
Reduced example: struct S
{
int a, b;
}
S get();
alias AliasSeq(T...) = T;
void main()
{
assert(get().tupleof == AliasSeq!(1, 2));
} Seems like there is some magic w.r.t. to comparing tuple variables. I'll have a look. |
b191a41
to
30c3247
Compare
(Rebased to restart the test suite now that #12258 was merged) |
Looks like the rewrite still doesn't understand: assert(( boo(4) = 2) == 2); assert(( maz(4) = 2) == 2); |
The druntime failure is ... weird: static assert(!__traits(compiles,
() @safe {
struct BadValue
{
int x;
this(this) @safe { *(cast(ubyte*)(null) + 100000) = 5; } // not @safe
alias x this;
}
BadValue[int] aa;
() @safe { auto x = aa.byKey.front; } ();
}
));
void issue15367()
{
void delegate() pure nothrow @nogc @safe dg;
assert(dg == dg);
} Remove the |
30c3247
to
a9c3170
Compare
Damn I really love this test. dlang/druntime#3412 |
a9c3170
to
b78746a
Compare
Not sure what to make of this yet. Test introduced in dlang/druntime#2467 |
2c8ea92
to
88cded2
Compare
Looks like Guessing from the diff:
After
EDIT: Not sure if this is the actual error. Removing the outdated EDIT 2: The order changed, fixed in dlang/druntime#3415 |
88cded2
to
7ccc4d6
Compare
7ccc4d6
to
0ac12ab
Compare
What causes these weird linker errors on OSX?
|
13c22bd
to
e017ed6
Compare
On the deprecation side of things, we've had those for a while:
Not sure how to best approach those. |
019e2bb
to
9d56407
Compare
Hum, this fails now because |
9d56407
to
4c5af08
Compare
ac55335
to
8d4baa9
Compare
I'm not sure whether building Druntime + Phobos with Two possible solutions:
|
Isn't that currently the case ? |
Guess we could check for deprecated |
Kindof. The call is emitted iff we run semantic on the function body - which includes auto functions and template instances in non-root modules AFAIU. |
So after a couple fixes:
|
8d4baa9
to
bb48cca
Compare
This allow OSX users to (more) easily run that script locally.
bb48cca
to
03d06c4
Compare
Putting this up there to see how people feel about it / what breaks.
Currently this switch is not usable as it creates a linker error in Phobos.
Having it the default would bring a lot of benefit - at the expense of breaking some code, e.g. non-copyable structs or structs with side effect.
Side note: That was the whole point of having
-preview=in
- make this kind of generic code easier to write.