Fix Issue 21651 - Unimported package doesn't error out when used as p…#12215
Fix Issue 21651 - Unimported package doesn't error out when used as p…#12215RazvanN7 merged 1 commit intodlang:masterfrom
Conversation
|
Is this the right fix ? To me it looks like a flaw in |
|
From what I know |
e7ad076 to
3f063d6
Compare
|
Thanks for your pull request and interest in making D better, @BorisCarvajal! 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#12215" |
| import dmd.expression; | ||
| import dmd.func; | ||
| import dmd.globals; | ||
| import dmd.glue; |
There was a problem hiding this comment.
Is this a result of fixing the bug?
There was a problem hiding this comment.
Well, it's to fix a instance of the bug in DMD.
There was a problem hiding this comment.
There are two lines a little below:
alias toSymbol = dmd.tocsym.toSymbol;
alias toSymbol = dmd.glue.toSymbol;
dmd.glue is not imported but is working because of the bug.
|
I kind of agree with @Geod24 . |
|
I've tracked the necessity of this additional check to #5426 |
|
I agree that maybe |
|
I should've noted that the compiler already shows the error if the qualified name is encapsulated as an expression (DotIdExp) vs a type. For example in the test @RazvanN7, So there is nothing to deprecate. |
The fact that we had to modify druntime and phobos to accomodate this change and we still have buildkite failing more than 10 projects is more than enough to warrant a deprecation. |
|
That deprecation already happened 5 years ago -> #5426 |
How do I get the deprecation to show up for ae? I don't see it. Are you sure that the deprecation you have in mind covers all the cases broken by this PR? |
It clearly didn't. Phobos and druntime compile with deprecations as errors, if there was a deprecation in place the code wouldn't have compiled and you wouldn't have had to fix them. So please make this a deprecation. |
|
Sorry, what I meant was that the intent of #5426 was to deprecate using fully-qualified names to bypass imports. Anyway, it seems adding a deprecation message is the way to go. |
|
What should be the deprecation period or version to put inside the |
|
@BorisCarvajal According to DIP1013 [1], the minimum required deprecation period is 10 non-patch releases. Since we have 6 releases per year [2], I guess that the minimum period is 20 months. I would round it up to 2 years just to have a well rounded number, but that is up to you. [1] https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1013.md |
45f68d3 to
8243f10
Compare
test/compilable/ice10598.d
Outdated
| compilable/imports/ice10598a.d(5): Deprecation: module imports.ice10598b is not accessible here, perhaps add 'static import imports.ice10598b;' | ||
| compilable/imports/ice10598a.d(5): Deprecation: module imports.ice10598b is not accessible here, perhaps add 'static import imports.ice10598b;' | ||
| --- | ||
| */ |
There was a problem hiding this comment.
maybe move this to fail_compilation and add REQUIRED_ARGS: -de
| @@ -0,0 +1,5 @@ | |||
| module imports.test21651a; | |||
|
|
|||
| // both statements should be error | |||
There was a problem hiding this comment.
The contents of this file should be moved to fail_compilation/test21651.d. That way we use only 2 files.
test/fail_compilation/test21651.d
Outdated
| /* TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/imports/test21651a.d(4): Deprecation: module imports.test21651b is not accessible here, perhaps add 'static import imports.test21651b;' | ||
| fail_compilation/imports/test21651a.d(5): Error: undefined identifier `test21651b` in package `imports`, perhaps add `static import imports.test21651b;` |
There was a problem hiding this comment.
This error is not necessary as it is covered already by other tests. Simply compile with -de and keep the minimum required lines of code to reproduce the code that this PR actually fixes.
| // @@@DEPRECATED_2.096@@@ | ||
| // Should be an error in 2.106. Just remove the deprecation call | ||
| // and uncomment the null assignment | ||
| deprecation(loc, "%s %s is not accessible here, perhaps add 'static import %s;'", sm.kind(), sm.toPrettyChars(), sm.toPrettyChars()); |
There was a problem hiding this comment.
here does not sound very professional. I suggest replacing it with the module name.
There was a problem hiding this comment.
Also, is the static really necessary?
There was a problem hiding this comment.
This is the exact message of the original deprecation.
RazvanN7
left a comment
There was a problem hiding this comment.
One last thing and we are good to go. This requires a changelog entry since it is deprecating behavior. I know that this is just a slipped case of a former deprecation, still, folks reading the changelog should be notified about it.
dda8bf2 to
aed8584
Compare
…art of fully qualified type
…art of fully qualified type
There are a few instances of phobos relying on this bug.