-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Fix Issue 7619 - Infer deprecated for template instances #10677
base: master
Are you sure you want to change the base?
Conversation
329bf9c
to
ed3746c
Compare
@Geod24 Could you have a look? |
6723367
to
6bcba3d
Compare
Is there a way to detect whether a symbol depends on a template parameter?
|
The resolution happens quite early. The Lines 2237 to 2330 in 49dfbe5
There is a |
I'll have to look deeper to be sure, but instinctively I'd say the result should happen at the |
Thanks, I'll look into that.
Not sure if i undertsood you correctly, but infering deprecated for the template scope would also hide valid deprecation messages e.g. for the usage of S in the previous example. I originally chose |
Which line in the test are you referring to ? |
|
Well if |
Ideally yes because the templated symbol is using deprecated stuff while not being deprecated itself.
F should not raise deprecation warnings but that would require to track these dependencies and which would probably require a lot of work. |
However it will trigger a deprecation warning. And if the other warning is fixed, this one will show up. template Transmogrify (T)
{
static if (is(typeof(T.foobar)))
alias Transmogriphy = FooBarTransmogriphier;
else
alias Transmogriphy = DefaultTransmogriphier;
} Now if you deprecate the Having some deprecations shows but not other would go against this. If we could do dependency tracking it'd be great, but DMD was not built with this in mind so it's a huge undertaking in itself. |
Okay, I think I got your point now. Assuming your example above, using |
Guess I'll try to infer |
6bcba3d
to
48aed92
Compare
test/fail_compilation/diag14875.d
Outdated
@@ -67,7 +64,7 @@ deprecated template Vaz(T) | |||
/* | |||
TEST_OUTPUT: | |||
--- | |||
fail_compilation/diag14875.d(75): Error: static assert: `0` is false | |||
fail_compilation/diag14875.d(72): Error: static assert: `0` is false |
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.
Just remove this and use -de
?
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.
Can do but I usually try to keep changes to existing tests as small as possible
test/fail_compilation/diag14875.d
Outdated
@@ -36,27 +36,24 @@ template Baz(T) | |||
/* | |||
TEST_OUTPUT: | |||
--- | |||
fail_compilation/diag14875.d(47): Deprecation: class `diag14875.Dep` is deprecated | |||
fail_compilation/diag14875.d(51): Deprecation: variable `diag14875.depVar` is deprecated | |||
fail_compilation/diag14875.d(44): Deprecation: class `diag14875.Dep` is deprecated |
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.
Actually looking at the issue, I think we should just merge both test cases, since this does not really test the original issue anymore.
Line 147 in 129f88f
This originates from this deprecated overload of Lines 471 to 475 in 129f88f
Seems like |
be6c2cb
to
2a1510e
Compare
2a1510e
to
41861ed
Compare
What is going on here? |
Worked on a lot of other stuff but I want to finish this PR in the future. |
1472a83
to
1ecb121
Compare
1ecb121
to
4669699
Compare
Template instances may use deprecated symbols that were passed as template parameters or selected based on an instance-specific condition. Previously DMD raised deprecation messages for the deprecated symbol at the point of instantiation AND substitution inside of the template code. The latter is cannot be suppressed by using `deprecated` because that will only apply to certain instantiations. This commit changes the behavior to check whether a deprecated symbol is used inside of a template instance and marks the instance as `deprecated` if found. That way only the actual usage of the instance will raise deprecation messages. Ideally this should only apply to deprecated symbols that depend on the template parameters but those dependencies are not traceable in general (`static if`, `compiles`, ...).
4669699
to
9cd6d44
Compare
Thanks for your pull request and interest in making D better, @MoonlightSentinel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
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
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#10677" |
@MoonlightSentinel It would be great if would manage to finish this. |
Template instances may use deprecated symbols that were passed as
template parameters or selected based on an instance-specific condition.
Previously DMD raised deprecation messages for the deprecated symbol at
the point of instantiation AND substitution inside of the template code.
The latter is cannot be suppressed by using
deprecated
because thatwill only apply to certain instantiations.
This commit changes the behavior to check whether a deprecated symbol
is used inside of a template instance and marks the instance as
deprecated
if found. That way only the actual usage of the instancewill raise deprecation messages.
Ideally this should only apply to deprecated symbols that depend on the
template parameters but those dependencies are not traceable in general
(
static if
,compiles
, ...).The current behaviour blocks dlang/phobos#7252 because
-checkaction=context
may instantiate templates with deprecated types (e.g.cfloat
) in deprecatedunittests
.