Skip to content
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

std.traits: Adapt unittest to pass with -preview=in #7609

Merged
merged 2 commits into from
Aug 29, 2020

Conversation

Geod24
Copy link
Member

@Geod24 Geod24 commented Aug 28, 2020

I'm using dlang/dmd#11632 as a way to adapt projects.
With this PR, it should pass for Phobos and the documentation tester.
I should probably add it to Buildkite like what Steven did for auto-decoding 🤔

…id constfold

With the new -preview=in check, the const-folding seems to be a bit
too aggressive when an rvalue is passed, meaning that the check might
fail (probably due to the code that initialize the temporary).
To avoid this issue, we simply wrap the assignment in a lambda that
will not be called, as there is no downside to that change.
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @Geod24!

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.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#7609"

@Geod24
Copy link
Member Author

Geod24 commented Aug 28, 2020

CC @wilzbach , this is what motivated dlang/dmd#11635 . As you can see the workaround isn't terrible either.

}
else
{
mixin(q{ struct S6 { void opAssign(in ref S5); } });
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this a mixin?

Copy link
Member Author

Choose a reason for hiding this comment

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

The error with -preview=in is in the parser (where "redundant storage class" checks are).
And yes, I hate it too and I'm having second thoughts, but it was the most consistent place to have it.

@MoonlightSentinel
Copy link
Contributor

I should probably add it to Buildkite like what Steven did for auto-decoding 🤔

Good idea, except implementing it for stable first ^^

@wilzbach
Copy link
Member

this is what motivated dlang/dmd#11635 .

Yeah, I'm well aware of the problem. We unfortunately did similar workarounds in the past, e.g.

phobos/std/typecons.d

Lines 7356 to 7362 in 6194b17

private enum isDIP1000 = __traits(compiles, () @safe {
int x;
int* p;
p = &x;
});
// excludes struct S; it's 'mixin Proxy!foo' doesn't compile with -dip1000
static if (isDIP1000) {} else

@Geod24 Geod24 force-pushed the std-traits-in-ref branch 2 times, most recently from 47ebc1e to 3a409ca Compare August 28, 2020 16:43
@Geod24 Geod24 force-pushed the std-traits-in-ref branch from 3a409ca to 461f083 Compare August 28, 2020 17:05
@thewilsonator thewilsonator merged commit aca1e12 into dlang:master Aug 29, 2020
@Geod24 Geod24 deleted the std-traits-in-ref branch August 29, 2020 12:29
wilzbach added a commit that referenced this pull request Aug 30, 2020
nordlow pushed a commit to nordlow/phobos that referenced this pull request Sep 10, 2020
* std.traits: Use delegates within some __traits(compiles) check to avoid constfold

With the new -preview=in check, the const-folding seems to be a bit
too aggressive when an rvalue is passed, meaning that the check might
fail (probably due to the code that initialize the temporary).
To avoid this issue, we simply wrap the assignment in a lambda that
will not be called, as there is no downside to that change.

* std.traits: Adapt unittest to pass with `-preview=in`
nordlow pushed a commit to nordlow/phobos that referenced this pull request Sep 10, 2020
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.

5 participants