From fdf80e6ac4b6fbc84c8ce6bb1df10ffa54951459 Mon Sep 17 00:00:00 2001 From: JinShil Date: Wed, 17 Apr 2019 23:32:45 +0900 Subject: [PATCH 01/25] Remove visiblity and lookup deprecation (Take 2) --- src/dmd/dscope.d | 75 +------------------ src/dmd/dsymbol.d | 12 ++- src/dmd/expressionsem.d | 41 +--------- src/dmd/traits.d | 2 +- src/dmd/typesem.d | 45 ++--------- test/compilable/checkimports1a.d | 19 +++++ test/compilable/checkimports1b.d | 18 +++++ test/compilable/checkimports1c.d | 18 +++++ .../diag12598.d | 3 +- test/compilable/dip22d.d | 10 +++ .../imports/diag12598a.d | 0 test/compilable/imports/dip22d.d | 5 ++ test/compilable/imports/dip22e.d | 4 + test/compilable/test15925.d | 18 ----- test/compilable/test19107.d | 20 ----- test/fail_compilation/checkimports1a.d | 20 ----- test/fail_compilation/checkimports1b.d | 20 ----- test/fail_compilation/checkimports1c.d | 20 ----- test/fail_compilation/checkimports2a.d | 15 ++-- test/fail_compilation/checkimports2b.d | 13 +--- test/fail_compilation/checkimports2c.d | 14 +--- test/fail_compilation/diag10169.d | 4 +- test/fail_compilation/diag5385.d | 32 ++++---- test/fail_compilation/dip22a.d | 21 +++--- test/fail_compilation/dip22b.d | 4 +- test/fail_compilation/dip22d.d | 12 --- test/fail_compilation/dip22e.d | 6 +- test/fail_compilation/fail10528.d | 16 ++-- test/fail_compilation/fail17625.d | 3 +- test/fail_compilation/fail18938.d | 3 +- test/fail_compilation/fail18979.d | 5 +- test/fail_compilation/fail262.d | 2 +- test/fail_compilation/fail313.d | 8 +- .../imports/imp15925.d | 0 .../imports/test15117a.d | 0 .../imports/test19107a.d | 0 .../imports/test19107b.d | 0 test/fail_compilation/lookup.d | 4 +- test/fail_compilation/test143.d | 2 +- .../test15177.d | 4 +- test/fail_compilation/test15785.d | 8 +- test/fail_compilation/test15785b.d | 8 +- test/fail_compilation/test15925.d | 19 +++++ test/fail_compilation/test19107.d | 21 ++++++ test/fail_compilation/test314.d | 10 +-- 45 files changed, 211 insertions(+), 373 deletions(-) create mode 100644 test/compilable/checkimports1a.d create mode 100644 test/compilable/checkimports1b.d create mode 100644 test/compilable/checkimports1c.d rename test/{fail_compilation => compilable}/diag12598.d (55%) create mode 100644 test/compilable/dip22d.d rename test/{fail_compilation => compilable}/imports/diag12598a.d (100%) create mode 100644 test/compilable/imports/dip22d.d create mode 100644 test/compilable/imports/dip22e.d delete mode 100644 test/compilable/test15925.d delete mode 100644 test/compilable/test19107.d delete mode 100644 test/fail_compilation/checkimports1a.d delete mode 100644 test/fail_compilation/checkimports1b.d delete mode 100644 test/fail_compilation/checkimports1c.d delete mode 100644 test/fail_compilation/dip22d.d rename test/{compilable => fail_compilation}/imports/imp15925.d (100%) rename test/{compilable => fail_compilation}/imports/test15117a.d (100%) rename test/{compilable => fail_compilation}/imports/test19107a.d (100%) rename test/{compilable => fail_compilation}/imports/test19107b.d (100%) rename test/{compilable => fail_compilation}/test15177.d (75%) create mode 100644 test/fail_compilation/test15925.d create mode 100644 test/fail_compilation/test19107.d diff --git a/src/dmd/dscope.d b/src/dmd/dscope.d index 9be99c05a201..e0d2fa5de28d 100644 --- a/src/dmd/dscope.d +++ b/src/dmd/dscope.d @@ -479,19 +479,6 @@ struct Scope if (this.flags & SCOPE.ignoresymbolvisibility) flags |= IgnoreSymbolVisibility; - Dsymbol sold = void; - if (global.params.bug10378 || global.params.check10378) - { - sold = searchScopes(flags | IgnoreSymbolVisibility); - if (!global.params.check10378) - return sold; - - if (ident == Id.dollar) // https://issues.dlang.org/show_bug.cgi?id=15825 - return sold; - - // Search both ways - } - // First look in local scopes Dsymbol s = searchScopes(flags | SearchLocalsOnly); version (LOGSEARCH) if (s) printMsg("-Scope.search() found local", s); @@ -500,68 +487,10 @@ struct Scope // Second look in imported modules s = searchScopes(flags | SearchImportsOnly); version (LOGSEARCH) if (s) printMsg("-Scope.search() found import", s); - - /** Still find private symbols, so that symbols that weren't access - * checked by the compiler remain usable. Once the deprecation is over, - * this should be moved to search_correct instead. - */ - if (!s && !(flags & IgnoreSymbolVisibility)) - { - s = searchScopes(flags | SearchLocalsOnly | IgnoreSymbolVisibility); - if (!s) - s = searchScopes(flags | SearchImportsOnly | IgnoreSymbolVisibility); - - if (s && !(flags & IgnoreErrors)) - .deprecation(loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), _module.toChars()); - version (LOGSEARCH) if (s) printMsg("-Scope.search() found imported private symbol", s); - } - } - if (global.params.check10378) - { - alias snew = s; - if (sold !is snew) - deprecation10378(loc, sold, snew); - if (global.params.bug10378) - s = sold; } return s; } - /* A helper function to show deprecation message for new name lookup rule. - */ - extern (D) static void deprecation10378(Loc loc, Dsymbol sold, Dsymbol snew) - { - // https://issues.dlang.org/show_bug.cgi?id=15857 - // - // The overloadset found via the new lookup rules is either - // equal or a subset of the overloadset found via the old - // lookup rules, so it suffices to compare the dimension to - // check for equality. - OverloadSet osold, osnew; - if (sold && (osold = sold.isOverloadSet()) !is null && - snew && (osnew = snew.isOverloadSet()) !is null && - osold.a.dim == osnew.a.dim) - return; - - OutBuffer buf; - buf.writestring("local import search method found "); - if (osold) - buf.printf("%s `%s` (%d overloads)", sold.kind(), sold.toPrettyChars(), cast(int) osold.a.dim); - else if (sold) - buf.printf("%s `%s`", sold.kind(), sold.toPrettyChars()); - else - buf.writestring("nothing"); - buf.writestring(" instead of "); - if (osnew) - buf.printf("%s `%s` (%d overloads)", snew.kind(), snew.toPrettyChars(), cast(int) osnew.a.dim); - else if (snew) - buf.printf("%s `%s`", snew.kind(), snew.toPrettyChars()); - else - buf.writestring("nothing"); - - deprecation(loc, buf.peekString()); - } - extern (C++) Dsymbol search_correct(Identifier ident) { if (global.gag) @@ -601,6 +530,10 @@ struct Scope return s; } + Dsymbol scopesym = null; + // search for exact name ignoring visibility first + if (auto s = search(Loc.initial, ident, &scopesym, IgnoreErrors | IgnoreSymbolVisibility)) + return s; return speller!scope_search_fp(ident.toChars()); } diff --git a/src/dmd/dsymbol.d b/src/dmd/dsymbol.d index 660b9312372f..41d7fb2acdb4 100644 --- a/src/dmd/dsymbol.d +++ b/src/dmd/dsymbol.d @@ -790,6 +790,9 @@ extern (C++) class Dsymbol : ASTNode if (global.gag) return null; // don't do it for speculative compiles; too time consuming + // search for exact name ignoring visibility first + if (auto s = search(Loc.initial, ident, IgnoreErrors | IgnoreSymbolVisibility)) + return s; return speller!symbol_search_fp(ident.toChars()); } @@ -1466,13 +1469,8 @@ public: { if (flags & SearchImportsOnly) continue; - // compatibility with -transition=import - // https://issues.dlang.org/show_bug.cgi?id=15925 - // SearchLocalsOnly should always get set for new lookup rules - if (global.params.check10378) - sflags |= (flags & SearchLocalsOnly); - else - sflags |= SearchLocalsOnly; + + sflags |= SearchLocalsOnly; } /* Don't find private members if ss is a module diff --git a/src/dmd/expressionsem.d b/src/dmd/expressionsem.d index 77f1fd5e2c8c..e0db1203c398 100644 --- a/src/dmd/expressionsem.d +++ b/src/dmd/expressionsem.d @@ -427,47 +427,13 @@ private Expression searchUFCS(Scope* sc, UnaExp ue, Identifier ident) if (sc.flags & SCOPE.ignoresymbolvisibility) flags |= IgnoreSymbolVisibility; - Dsymbol sold = void; - if (global.params.bug10378 || global.params.check10378) - { - sold = searchScopes(flags | IgnoreSymbolVisibility); - if (!global.params.check10378) - { - s = sold; - goto Lsearchdone; - } - } - // First look in local scopes s = searchScopes(flags | SearchLocalsOnly); if (!s) { // Second look in imported modules s = searchScopes(flags | SearchImportsOnly); - - /** Still find private symbols, so that symbols that weren't access - * checked by the compiler remain usable. Once the deprecation is over, - * this should be moved to search_correct instead. - */ - if (!s && !(flags & IgnoreSymbolVisibility)) - { - s = searchScopes(flags | SearchLocalsOnly | IgnoreSymbolVisibility); - if (!s) - s = searchScopes(flags | SearchImportsOnly | IgnoreSymbolVisibility); - - if (s) - .deprecation(loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toChars()); - } } - if (global.params.check10378) - { - alias snew = s; - if (sold !is snew) - Scope.deprecation10378(loc, sold, snew); - if (global.params.bug10378) - s = sold; - } -Lsearchdone: if (!s) return ue.e1.type.Type.getProperty(loc, ident, 0); @@ -11028,11 +10994,8 @@ Expression semanticY(DotIdExp exp, Scope* sc, int flag) */ if (s && !(sc.flags & SCOPE.ignoresymbolvisibility) && !symbolIsVisible(sc._module, s)) { - if (s.isDeclaration()) - error(exp.loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toChars()); - else - deprecation(exp.loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toChars()); - // s = null; + error(exp.loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toChars()); + s = null; } if (s) { diff --git a/src/dmd/traits.d b/src/dmd/traits.d index b455991da5c7..1bbabba8a95f 100644 --- a/src/dmd/traits.d +++ b/src/dmd/traits.d @@ -736,7 +736,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc) return dimError(1); Scope* sc2 = sc.push(); - sc2.flags = sc.flags | SCOPE.noaccesscheck; + sc2.flags = sc.flags | SCOPE.noaccesscheck | SCOPE.ignoresymbolvisibility; bool ok = TemplateInstance.semanticTiargs(e.loc, sc2, e.args, 1); sc2.pop(); if (!ok) diff --git a/src/dmd/typesem.d b/src/dmd/typesem.d index 4d114982e26b..e793c7b08607 100644 --- a/src/dmd/typesem.d +++ b/src/dmd/typesem.d @@ -236,8 +236,8 @@ private void resolveHelper(TypeQualified mt, const ref Loc loc, Scope* sc, Dsymb Dsymbol sm = s.searchX(loc, sc, id, flags); if (sm && !(sc.flags & SCOPE.ignoresymbolvisibility) && !symbolIsVisible(sc, sm)) { - .deprecation(loc, "`%s` is not visible from module `%s`", sm.toPrettyChars(), sc._module.toChars()); - // sm = null; + .error(loc, "`%s` is not visible from module `%s`", sm.toPrettyChars(), sc._module.toChars()); + sm = null; } if (global.errors != errorsave) { @@ -3433,23 +3433,8 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag) { int flags = sc.flags & SCOPE.ignoresymbolvisibility ? IgnoreSymbolVisibility : 0; - Dsymbol sold = void; - if (global.params.bug10378 || global.params.check10378) - { - sold = mt.sym.search(e.loc, ident, flags); - if (!global.params.check10378) - return sold; - } - auto s = mt.sym.search(e.loc, ident, flags | IgnorePrivateImports); - if (global.params.check10378) - { - alias snew = s; - if (sold !is snew) - Scope.deprecation10378(e.loc, sold, snew); - if (global.params.bug10378) - s = sold; - } + return s; } @@ -3461,8 +3446,8 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag) } if (!(sc.flags & SCOPE.ignoresymbolvisibility) && !symbolIsVisible(sc, s)) { - .deprecation(e.loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toPrettyChars()); - // return noMember(sc, e, ident, flag); + .error(e.loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toPrettyChars()); + return noMember(mt, sc, e, ident, flag); } if (!s.isFuncDeclaration()) // because of overloading { @@ -3740,13 +3725,6 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag) Dsymbol searchSym() { int flags = sc.flags & SCOPE.ignoresymbolvisibility ? IgnoreSymbolVisibility : 0; - Dsymbol sold = void; - if (global.params.bug10378 || global.params.check10378) - { - sold = mt.sym.search(e.loc, ident, flags | IgnoreSymbolVisibility); - if (!global.params.check10378) - return sold; - } auto s = mt.sym.search(e.loc, ident, flags | SearchLocalsOnly); if (!s && !(flags & IgnoreSymbolVisibility)) @@ -3755,14 +3733,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag) if (s && !(flags & IgnoreErrors)) .deprecation(e.loc, "`%s` is not visible from class `%s`", s.toPrettyChars(), mt.sym.toChars()); } - if (global.params.check10378) - { - alias snew = s; - if (sold !is snew) - Scope.deprecation10378(e.loc, sold, snew); - if (global.params.bug10378) - s = sold; - } + return s; } @@ -3914,8 +3885,8 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag) } if (!(sc.flags & SCOPE.ignoresymbolvisibility) && !symbolIsVisible(sc, s)) { - .deprecation(e.loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toPrettyChars()); - // return noMember(sc, e, ident, flag); + .error(e.loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toPrettyChars()); + return noMember(mt, sc, e, ident, flag); } if (!s.isFuncDeclaration()) // because of overloading { diff --git a/test/compilable/checkimports1a.d b/test/compilable/checkimports1a.d new file mode 100644 index 000000000000..7f18418fc09d --- /dev/null +++ b/test/compilable/checkimports1a.d @@ -0,0 +1,19 @@ +// REQUIRED_ARGS: +/* +TEST_OUTPUT: +--- +--- +*/ + + +// new lookup + information +class C +{ + void f() + { + import imports.diag12598a; + lines ~= ""; + } + + string[] lines; +} diff --git a/test/compilable/checkimports1b.d b/test/compilable/checkimports1b.d new file mode 100644 index 000000000000..742bd0b3f244 --- /dev/null +++ b/test/compilable/checkimports1b.d @@ -0,0 +1,18 @@ +// REQUIRED_ARGS: +/* +TEST_OUTPUT: +--- +--- +*/ + +// old lookup + information +class C +{ + void f() + { + import imports.diag12598a; + lines ~= ""; + } + + string[] lines; +} diff --git a/test/compilable/checkimports1c.d b/test/compilable/checkimports1c.d new file mode 100644 index 000000000000..93555ae6de23 --- /dev/null +++ b/test/compilable/checkimports1c.d @@ -0,0 +1,18 @@ +// REQUIRED_ARGS: +/* +TEST_OUTPUT: +--- +--- +*/ + +// old lookup + information (the order of switches is reverse) +class C +{ + void f() + { + import imports.diag12598a; + lines ~= ""; + } + + string[] lines; +} diff --git a/test/fail_compilation/diag12598.d b/test/compilable/diag12598.d similarity index 55% rename from test/fail_compilation/diag12598.d rename to test/compilable/diag12598.d index a5fe32cd8311..c53b418acb8d 100644 --- a/test/fail_compilation/diag12598.d +++ b/test/compilable/diag12598.d @@ -1,8 +1,7 @@ /* -REQUIRED_ARGS: -revert=import +REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/diag12598.d(14): Error: `lines` is a `struct` definition and cannot be modified --- */ diff --git a/test/compilable/dip22d.d b/test/compilable/dip22d.d new file mode 100644 index 000000000000..e8f26655a8ea --- /dev/null +++ b/test/compilable/dip22d.d @@ -0,0 +1,10 @@ +/* +REQUIRED_ARGS: +TEST_OUTPUT: +--- +--- +*/ +import imports.dip22d; +import imports.dip22e; + +Foo foo; diff --git a/test/fail_compilation/imports/diag12598a.d b/test/compilable/imports/diag12598a.d similarity index 100% rename from test/fail_compilation/imports/diag12598a.d rename to test/compilable/imports/diag12598a.d diff --git a/test/compilable/imports/dip22d.d b/test/compilable/imports/dip22d.d new file mode 100644 index 000000000000..9f80442e4b41 --- /dev/null +++ b/test/compilable/imports/dip22d.d @@ -0,0 +1,5 @@ +module imports.dip22d; + +private struct Foo {} +private void foo() {} +private void bar() {} diff --git a/test/compilable/imports/dip22e.d b/test/compilable/imports/dip22e.d new file mode 100644 index 000000000000..3464e605d5d3 --- /dev/null +++ b/test/compilable/imports/dip22e.d @@ -0,0 +1,4 @@ +module imports.dip22e; + +public struct Foo {} +public void bar(int) {} diff --git a/test/compilable/test15925.d b/test/compilable/test15925.d deleted file mode 100644 index 00ba706b87fb..000000000000 --- a/test/compilable/test15925.d +++ /dev/null @@ -1,18 +0,0 @@ -/* REQUIRED_ARGS: -revert=import -transition=checkimports -PERMUTE_ARGS: -TEST_OUTPUT: ---- -compilable/test15925.d(17): Deprecation: local import search method found variable `imp15925.X` instead of nothing ---- -*/ - -mixin template Import() -{ - import imports.imp15925; -} - -class Foo -{ - mixin Import!(); - static assert(X == 1); -} diff --git a/test/compilable/test19107.d b/test/compilable/test19107.d deleted file mode 100644 index bfa64d285cb0..000000000000 --- a/test/compilable/test19107.d +++ /dev/null @@ -1,20 +0,0 @@ -// REQUIRED_ARGS: -dw -/* -TEST_OUTPUT: ---- -compilable/test19107.d(14): Deprecation: `imports.test19107b.I` is not visible from module `test19107` ---- -*/ - -// https://issues.dlang.org/show_bug.cgi?id=19107 - -import imports.test19107b; - -void all(alias pred, T)(T t) - if (is(typeof(I!pred(t)))) -{ } - -void main(string[] args) -{ - args.all!(c => c); -} diff --git a/test/fail_compilation/checkimports1a.d b/test/fail_compilation/checkimports1a.d deleted file mode 100644 index 070b4bf11b6d..000000000000 --- a/test/fail_compilation/checkimports1a.d +++ /dev/null @@ -1,20 +0,0 @@ -// REQUIRED_ARGS: -transition=checkimports -de -/* -TEST_OUTPUT: ---- -fail_compilation/checkimports1a.d(16): Deprecation: local import search method found struct `imports.diag12598a.lines` instead of variable `checkimports1a.C.lines` ---- -*/ - - -// new lookup + information -class C -{ - void f() - { - import imports.diag12598a; - lines ~= ""; - } - - string[] lines; -} diff --git a/test/fail_compilation/checkimports1b.d b/test/fail_compilation/checkimports1b.d deleted file mode 100644 index 3594ff240f72..000000000000 --- a/test/fail_compilation/checkimports1b.d +++ /dev/null @@ -1,20 +0,0 @@ -// REQUIRED_ARGS: -revert=import -transition=checkimports -/* -TEST_OUTPUT: ---- -fail_compilation/checkimports1b.d(16): Deprecation: local import search method found struct `imports.diag12598a.lines` instead of variable `checkimports1b.C.lines` -fail_compilation/checkimports1b.d(16): Error: `lines` is a `struct` definition and cannot be modified ---- -*/ - -// old lookup + information -class C -{ - void f() - { - import imports.diag12598a; - lines ~= ""; - } - - string[] lines; -} diff --git a/test/fail_compilation/checkimports1c.d b/test/fail_compilation/checkimports1c.d deleted file mode 100644 index 3c8dce1db817..000000000000 --- a/test/fail_compilation/checkimports1c.d +++ /dev/null @@ -1,20 +0,0 @@ -// REQUIRED_ARGS: -transition=checkimports -revert=import -/* -TEST_OUTPUT: ---- -fail_compilation/checkimports1c.d(16): Deprecation: local import search method found struct `imports.diag12598a.lines` instead of variable `checkimports1c.C.lines` -fail_compilation/checkimports1c.d(16): Error: `lines` is a `struct` definition and cannot be modified ---- -*/ - -// old lookup + information (the order of switches is reverse) -class C -{ - void f() - { - import imports.diag12598a; - lines ~= ""; - } - - string[] lines; -} diff --git a/test/fail_compilation/checkimports2a.d b/test/fail_compilation/checkimports2a.d index 33fc520a579c..abec4242eeca 100644 --- a/test/fail_compilation/checkimports2a.d +++ b/test/fail_compilation/checkimports2a.d @@ -1,16 +1,11 @@ -// REQUIRED_ARGS: -transition=checkimports +// REQUIRED_ARGS: /* TEST_OUTPUT: --- -fail_compilation/checkimports2a.d(26): Deprecation: local import search method found variable `imports.imp2.X` instead of variable `checkimports2a.X` -fail_compilation/checkimports2a.d(32): Deprecation: local import search method found variable `imports.imp2.X` instead of nothing -fail_compilation/checkimports2a.d(32): Error: no property `X` for type `checkimports2a.B` -fail_compilation/checkimports2a.d(32): while evaluating: `static assert((B).X == 0)` -fail_compilation/checkimports2a.d(33): Deprecation: local import search method found variable `imports.imp2.Y` instead of nothing -fail_compilation/checkimports2a.d(33): Error: no property `Y` for type `checkimports2a.B` -fail_compilation/checkimports2a.d(33): while evaluating: `static assert((B).Y == 2)` -fail_compilation/checkimports2a.d(35): Deprecation: local import search method found variable `imports.imp2.X` instead of variable `checkimports2a.X` -fail_compilation/checkimports2a.d(36): Deprecation: local import search method found variable `imports.imp2.Y` instead of variable `imports.imp1.Y` +fail_compilation/checkimports2a.d(27): Error: no property `X` for type `checkimports2a.B`, did you mean `imports.imp2.X`? +fail_compilation/checkimports2a.d(27): while evaluating: `static assert((B).X == 0)` +fail_compilation/checkimports2a.d(28): Error: no property `Y` for type `checkimports2a.B`, did you mean `imports.imp2.Y`? +fail_compilation/checkimports2a.d(28): while evaluating: `static assert((B).Y == 2)` --- */ diff --git a/test/fail_compilation/checkimports2b.d b/test/fail_compilation/checkimports2b.d index 72a5f95fbedf..8b99fdc54058 100644 --- a/test/fail_compilation/checkimports2b.d +++ b/test/fail_compilation/checkimports2b.d @@ -1,17 +1,8 @@ -// REQUIRED_ARGS: -revert=import -transition=checkimports -de +// REQUIRED_ARGS: /* TEST_OUTPUT: --- -fail_compilation/checkimports2b.d(27): Deprecation: local import search method found variable `imports.imp2.X` instead of variable `checkimports2b.X` -fail_compilation/checkimports2b.d(27): while evaluating: `static assert(2 == 2)` -fail_compilation/checkimports2b.d(33): Deprecation: local import search method found variable `imports.imp2.X` instead of nothing -fail_compilation/checkimports2b.d(33): while evaluating: `static assert(2 == 2)` -fail_compilation/checkimports2b.d(34): Deprecation: local import search method found variable `imports.imp2.Y` instead of nothing -fail_compilation/checkimports2b.d(34): while evaluating: `static assert(2 == 2)` -fail_compilation/checkimports2b.d(36): Deprecation: local import search method found variable `imports.imp2.X` instead of variable `checkimports2b.X` -fail_compilation/checkimports2b.d(36): while evaluating: `static assert(2 == 2)` -fail_compilation/checkimports2b.d(37): Deprecation: local import search method found variable `imports.imp2.Y` instead of variable `imports.imp1.Y` -fail_compilation/checkimports2b.d(37): while evaluating: `static assert(2 == 2)` +fail_compilation/checkimports2b.d(18): Error: static assert: `0 == 2` is false --- */ diff --git a/test/fail_compilation/checkimports2c.d b/test/fail_compilation/checkimports2c.d index 0c25b1c19029..4208dcdf6b2a 100644 --- a/test/fail_compilation/checkimports2c.d +++ b/test/fail_compilation/checkimports2c.d @@ -1,18 +1,8 @@ -// REQUIRED_ARGS: -transition=checkimports -revert=import -de +// REQUIRED_ARGS: /* TEST_OUTPUT: --- - -fail_compilation/checkimports2c.d(28): Deprecation: local import search method found variable `imports.imp2.X` instead of variable `checkimports2c.X` -fail_compilation/checkimports2c.d(28): while evaluating: `static assert(2 == 2)` -fail_compilation/checkimports2c.d(34): Deprecation: local import search method found variable `imports.imp2.X` instead of nothing -fail_compilation/checkimports2c.d(34): while evaluating: `static assert(2 == 2)` -fail_compilation/checkimports2c.d(35): Deprecation: local import search method found variable `imports.imp2.Y` instead of nothing -fail_compilation/checkimports2c.d(35): while evaluating: `static assert(2 == 2)` -fail_compilation/checkimports2c.d(37): Deprecation: local import search method found variable `imports.imp2.X` instead of variable `checkimports2c.X` -fail_compilation/checkimports2c.d(37): while evaluating: `static assert(2 == 2)` -fail_compilation/checkimports2c.d(38): Deprecation: local import search method found variable `imports.imp2.Y` instead of variable `imports.imp1.Y` -fail_compilation/checkimports2c.d(38): while evaluating: `static assert(2 == 2)` +fail_compilation/checkimports2c.d(18): Error: static assert: `0 == 2` is false --- */ diff --git a/test/fail_compilation/diag10169.d b/test/fail_compilation/diag10169.d index d1636fce8aa0..3b20b562aca9 100644 --- a/test/fail_compilation/diag10169.d +++ b/test/fail_compilation/diag10169.d @@ -1,8 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/diag10169.d(12): Deprecation: `imports.a10169.B.x` is not visible from module `diag10169` -fail_compilation/diag10169.d(12): Error: struct `imports.a10169.B` member `x` is not accessible +fail_compilation/diag10169.d(12): Error: `imports.a10169.B.x` is not visible from module `diag10169` +fail_compilation/diag10169.d(12): Error: no property `x` for type `B`, did you mean `imports.a10169.B.x`? --- */ import imports.a10169; diff --git a/test/fail_compilation/diag5385.d b/test/fail_compilation/diag5385.d index 5d4e93678827..5e4aa4271579 100644 --- a/test/fail_compilation/diag5385.d +++ b/test/fail_compilation/diag5385.d @@ -1,22 +1,22 @@ /* TEST_OUTPUT: --- -fail_compilation/diag5385.d(27): Deprecation: `imports.fail5385.C.privX` is not visible from module `diag5385` -fail_compilation/diag5385.d(27): Error: class `imports.fail5385.C` member `privX` is not accessible -fail_compilation/diag5385.d(28): Deprecation: `imports.fail5385.C.packX` is not visible from module `diag5385` -fail_compilation/diag5385.d(28): Error: class `imports.fail5385.C` member `packX` is not accessible -fail_compilation/diag5385.d(29): Deprecation: `imports.fail5385.C.privX2` is not visible from module `diag5385` -fail_compilation/diag5385.d(29): Error: class `imports.fail5385.C` member `privX2` is not accessible -fail_compilation/diag5385.d(30): Deprecation: `imports.fail5385.C.packX2` is not visible from module `diag5385` -fail_compilation/diag5385.d(30): Error: class `imports.fail5385.C` member `packX2` is not accessible -fail_compilation/diag5385.d(31): Deprecation: `imports.fail5385.S.privX` is not visible from module `diag5385` -fail_compilation/diag5385.d(31): Error: struct `imports.fail5385.S` member `privX` is not accessible -fail_compilation/diag5385.d(32): Deprecation: `imports.fail5385.S.packX` is not visible from module `diag5385` -fail_compilation/diag5385.d(32): Error: struct `imports.fail5385.S` member `packX` is not accessible -fail_compilation/diag5385.d(33): Deprecation: `imports.fail5385.S.privX2` is not visible from module `diag5385` -fail_compilation/diag5385.d(33): Error: struct `imports.fail5385.S` member `privX2` is not accessible -fail_compilation/diag5385.d(34): Deprecation: `imports.fail5385.S.packX2` is not visible from module `diag5385` -fail_compilation/diag5385.d(34): Error: struct `imports.fail5385.S` member `packX2` is not accessible +fail_compilation/diag5385.d(27): Error: `imports.fail5385.C.privX` is not visible from module `diag5385` +fail_compilation/diag5385.d(27): Error: no property `privX` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.privX`? +fail_compilation/diag5385.d(28): Error: `imports.fail5385.C.packX` is not visible from module `diag5385` +fail_compilation/diag5385.d(28): Error: no property `packX` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.packX`? +fail_compilation/diag5385.d(29): Error: `imports.fail5385.C.privX2` is not visible from module `diag5385` +fail_compilation/diag5385.d(29): Error: no property `privX2` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.privX2`? +fail_compilation/diag5385.d(30): Error: `imports.fail5385.C.packX2` is not visible from module `diag5385` +fail_compilation/diag5385.d(30): Error: no property `packX2` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.packX2`? +fail_compilation/diag5385.d(31): Error: `imports.fail5385.S.privX` is not visible from module `diag5385` +fail_compilation/diag5385.d(31): Error: no property `privX` for type `S`, did you mean `imports.fail5385.S.privX`? +fail_compilation/diag5385.d(32): Error: `imports.fail5385.S.packX` is not visible from module `diag5385` +fail_compilation/diag5385.d(32): Error: no property `packX` for type `S`, did you mean `imports.fail5385.S.packX`? +fail_compilation/diag5385.d(33): Error: `imports.fail5385.S.privX2` is not visible from module `diag5385` +fail_compilation/diag5385.d(33): Error: no property `privX2` for type `S`, did you mean `imports.fail5385.S.privX2`? +fail_compilation/diag5385.d(34): Error: `imports.fail5385.S.packX2` is not visible from module `diag5385` +fail_compilation/diag5385.d(34): Error: no property `packX2` for type `S`, did you mean `imports.fail5385.S.packX2`? --- */ diff --git a/test/fail_compilation/dip22a.d b/test/fail_compilation/dip22a.d index 1ba4e861dc2b..b5daabb119dd 100644 --- a/test/fail_compilation/dip22a.d +++ b/test/fail_compilation/dip22a.d @@ -1,17 +1,16 @@ /* -REQUIRED_ARGS: -de +REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/dip22a.d(21): Deprecation: `imports.dip22a.Klass.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(21): Error: class `imports.dip22a.Klass` member `bar` is not accessible -fail_compilation/dip22a.d(22): Deprecation: `imports.dip22a.Struct.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(22): Error: struct `imports.dip22a.Struct` member `bar` is not accessible -fail_compilation/dip22a.d(23): Error: `imports.dip22a.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(23): Error: function `imports.dip22a.bar` is not accessible from module `dip22a` -fail_compilation/dip22a.d(24): Error: `imports.dip22a.Template!int.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(24): Error: function `imports.dip22a.Template!int.bar` is not accessible from module `dip22a` -fail_compilation/dip22a.d(25): Deprecation: `imports.dip22a.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(25): Error: function `imports.dip22a.bar` is not accessible from module `dip22a` +fail_compilation/dip22a.d(20): Error: `imports.dip22a.Klass.bar` is not visible from module `dip22a` +fail_compilation/dip22a.d(20): Error: no property `bar` for type `imports.dip22a.Klass`, did you mean `imports.dip22a.Klass.bar`? +fail_compilation/dip22a.d(21): Error: `imports.dip22a.Struct.bar` is not visible from module `dip22a` +fail_compilation/dip22a.d(21): Error: no property `bar` for type `Struct`, did you mean `imports.dip22a.Struct.bar`? +fail_compilation/dip22a.d(22): Error: `imports.dip22a.bar` is not visible from module `dip22a` +fail_compilation/dip22a.d(22): Error: undefined identifier `bar` in module `imports.dip22a`, did you mean function `bar`? +fail_compilation/dip22a.d(23): Error: `imports.dip22a.Template!int.bar` is not visible from module `dip22a` +fail_compilation/dip22a.d(23): Error: no property `bar` for type `void` +fail_compilation/dip22a.d(24): Error: no property `bar` for type `int` --- */ import imports.dip22a; diff --git a/test/fail_compilation/dip22b.d b/test/fail_compilation/dip22b.d index 538408ace43a..3999f2ae77d7 100644 --- a/test/fail_compilation/dip22b.d +++ b/test/fail_compilation/dip22b.d @@ -1,8 +1,8 @@ /* -REQUIRED_ARGS: -de +REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/dip22b.d(12): Deprecation: `pkg.dip22c.Foo` is not visible from module `dip22` +fail_compilation/dip22b.d(12): Error: undefined identifier `Foo`, did you mean struct `Foo`? --- */ module pkg.dip22; diff --git a/test/fail_compilation/dip22d.d b/test/fail_compilation/dip22d.d deleted file mode 100644 index 64257d10df95..000000000000 --- a/test/fail_compilation/dip22d.d +++ /dev/null @@ -1,12 +0,0 @@ -/* -REQUIRED_ARGS: -revert=import -TEST_OUTPUT: ---- -fail_compilation/dip22d.d(12): Error: `imports.dip22d.Foo` at fail_compilation/imports/dip22d.d(3) conflicts with `imports.dip22e.Foo` at fail_compilation/imports/dip22e.d(3) -fail_compilation/dip22d.d(12): Error: module `dip22d` struct `imports.dip22d.Foo` is `private` ---- -*/ -import imports.dip22d; -import imports.dip22e; - -Foo foo; diff --git a/test/fail_compilation/dip22e.d b/test/fail_compilation/dip22e.d index 8786b899253f..81dfbbb63e73 100644 --- a/test/fail_compilation/dip22e.d +++ b/test/fail_compilation/dip22e.d @@ -1,10 +1,8 @@ /* -REQUIRED_ARGS: -transition=checkimports -de +REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/dip22e.d(16): Deprecation: `imports.dip22d.foo` is not visible from module `dip22e` -fail_compilation/dip22e.d(16): Error: function `imports.dip22d.foo` is not accessible from module `dip22e` -fail_compilation/dip22e.d(17): Deprecation: local import search method found overloadset `dip22e.bar` (1 overloads) instead of function `imports.dip22e.bar` +fail_compilation/dip22e.d(14): Error: undefined identifier `foo`, did you mean function `foo`? --- */ diff --git a/test/fail_compilation/fail10528.d b/test/fail_compilation/fail10528.d index 1b26d1778c0f..1806828cdf0d 100644 --- a/test/fail_compilation/fail10528.d +++ b/test/fail_compilation/fail10528.d @@ -1,17 +1,17 @@ /* TEST_OUTPUT: --- -fail_compilation/fail10528.d(23): Error: module `fail10528` variable `a10528.a` is `private` -fail_compilation/fail10528.d(23): Deprecation: `a10528.a` is not visible from module `fail10528` +fail_compilation/fail10528.d(23): Error: undefined identifier `a`, did you mean variable `a`? fail_compilation/fail10528.d(24): Error: `a10528.a` is not visible from module `fail10528` -fail_compilation/fail10528.d(26): Error: module `fail10528` enum member `a10528.b` is `private` -fail_compilation/fail10528.d(26): Deprecation: `a10528.b` is not visible from module `fail10528` +fail_compilation/fail10528.d(24): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? +fail_compilation/fail10528.d(26): Error: undefined identifier `b`, did you mean enum member `b`? fail_compilation/fail10528.d(27): Error: `a10528.b` is not visible from module `fail10528` -fail_compilation/fail10528.d(29): Deprecation: `a10528.S.c` is not visible from module `fail10528` -fail_compilation/fail10528.d(29): Error: variable `a10528.S.c` is not accessible from module `fail10528` +fail_compilation/fail10528.d(27): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? +fail_compilation/fail10528.d(29): Error: `a10528.S.c` is not visible from module `fail10528` +fail_compilation/fail10528.d(29): Error: no property `c` for type `S`, did you mean `a10528.S.c`? fail_compilation/fail10528.d(30): Error: variable `a10528.S.c` is not accessible from module `fail10528` -fail_compilation/fail10528.d(32): Deprecation: `a10528.C.d` is not visible from module `fail10528` -fail_compilation/fail10528.d(32): Error: variable `a10528.C.d` is not accessible from module `fail10528` +fail_compilation/fail10528.d(32): Error: `a10528.C.d` is not visible from module `fail10528` +fail_compilation/fail10528.d(32): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? fail_compilation/fail10528.d(33): Error: variable `a10528.C.d` is not accessible from module `fail10528` --- */ diff --git a/test/fail_compilation/fail17625.d b/test/fail_compilation/fail17625.d index da1736656797..0689545f59fb 100644 --- a/test/fail_compilation/fail17625.d +++ b/test/fail_compilation/fail17625.d @@ -1,8 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail17625.d(16): Deprecation: `b17625.boo` is not visible from module `fail17625` -fail_compilation/fail17625.d(16): Error: function `b17625.boo` is not accessible from module `fail17625` +fail_compilation/fail17625.d(15): Error: undefined identifier `boo`, did you mean function `boo`? --- */ diff --git a/test/fail_compilation/fail18938.d b/test/fail_compilation/fail18938.d index f7f917679251..671271dc0687 100644 --- a/test/fail_compilation/fail18938.d +++ b/test/fail_compilation/fail18938.d @@ -2,8 +2,7 @@ /* TEST_OUTPUT: --- -fail_compilation/imports/test18938b/file.d(20): Deprecation: `std.algorithm.setops.No` is not visible from module `file` -fail_compilation/imports/test18938b/file.d(9): Error: `map(Range)(Range r) if (isInputRange!(Unqual!Range))` has no effect +fail_compilation/imports/test18938b/file.d(20): Error: undefined identifier `No`, did you mean alias `No`? --- */ diff --git a/test/fail_compilation/fail18979.d b/test/fail_compilation/fail18979.d index 314c9671a936..e30f2242948d 100644 --- a/test/fail_compilation/fail18979.d +++ b/test/fail_compilation/fail18979.d @@ -2,8 +2,9 @@ /* TEST_OUTPUT: --- -fail_compilation/fail18979.d(13): Deprecation: `imports.imp18979.Foo.__ctor(A)(A a)` is not visible from module `fail18979` ---- +fail_compilation/fail18979.d(14): Error: `imports.imp18979.Foo.__ctor(A)(A a)` is not visible from module `fail18979` +fail_compilation/fail18979.d(14): Error: no property `__ctor` for type `Foo`, did you mean `imports.imp18979.Foo.__ctor(A)(A a)`? +---- */ import imports.imp18979; diff --git a/test/fail_compilation/fail262.d b/test/fail_compilation/fail262.d index f59ca89d36d8..7c92c7c18261 100644 --- a/test/fail_compilation/fail262.d +++ b/test/fail_compilation/fail262.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail262.d(23): Error: function `fail262.B.f` does not override any function +fail_compilation/fail262.d(23): Error: function `const void fail262.B.f()` does not override any function, did you mean to override `shared const void fail262.A.f()`? --- */ diff --git a/test/fail_compilation/fail313.d b/test/fail_compilation/fail313.d index 81e6addd9704..0b4bd2a2f056 100644 --- a/test/fail_compilation/fail313.d +++ b/test/fail_compilation/fail313.d @@ -1,11 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/fail313.d(17): Error: module `imports.b313` is not accessible here, perhaps add `static import imports.b313;` -fail_compilation/fail313.d(24): Deprecation: `imports.a313.core` is not visible from module `test313` -fail_compilation/fail313.d(24): Error: package `core.stdc` is not accessible here -fail_compilation/fail313.d(24): Error: module `core.stdc.stdio` is not accessible here, perhaps add `static import core.stdc.stdio;` -fail_compilation/fail313.d(29): Error: package `imports.pkg313` is not accessible here, perhaps add `static import imports.pkg313;` +fail_compilation/fail313.d(15): Error: module `imports.b313` is not accessible here, perhaps add `static import imports.b313;` +fail_compilation/fail313.d(22): Error: undefined identifier `core`, did you mean import `core`? +fail_compilation/fail313.d(27): Error: package `imports.pkg313` is not accessible here, perhaps add `static import imports.pkg313;` --- */ module test313; diff --git a/test/compilable/imports/imp15925.d b/test/fail_compilation/imports/imp15925.d similarity index 100% rename from test/compilable/imports/imp15925.d rename to test/fail_compilation/imports/imp15925.d diff --git a/test/compilable/imports/test15117a.d b/test/fail_compilation/imports/test15117a.d similarity index 100% rename from test/compilable/imports/test15117a.d rename to test/fail_compilation/imports/test15117a.d diff --git a/test/compilable/imports/test19107a.d b/test/fail_compilation/imports/test19107a.d similarity index 100% rename from test/compilable/imports/test19107a.d rename to test/fail_compilation/imports/test19107a.d diff --git a/test/compilable/imports/test19107b.d b/test/fail_compilation/imports/test19107b.d similarity index 100% rename from test/compilable/imports/test19107b.d rename to test/fail_compilation/imports/test19107b.d diff --git a/test/fail_compilation/lookup.d b/test/fail_compilation/lookup.d index f5ff0adde78e..5ef7af9e9908 100644 --- a/test/fail_compilation/lookup.d +++ b/test/fail_compilation/lookup.d @@ -1,9 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/lookup.d(23): Error: no property `X` for type `lookup.B` +fail_compilation/lookup.d(23): Error: no property `X` for type `lookup.B`, did you mean `imports.imp2.X`? fail_compilation/lookup.d(23): while evaluating: `static assert((B).X == 0)` -fail_compilation/lookup.d(24): Error: no property `Y` for type `lookup.B` +fail_compilation/lookup.d(24): Error: no property `Y` for type `lookup.B`, did you mean `imports.imp2.Y`? fail_compilation/lookup.d(24): while evaluating: `static assert((B).Y == 2)` --- */ diff --git a/test/fail_compilation/test143.d b/test/fail_compilation/test143.d index 7b61dfcc9858..2d1192424833 100644 --- a/test/fail_compilation/test143.d +++ b/test/fail_compilation/test143.d @@ -3,7 +3,7 @@ /* TEST_OUTPUT: --- -fail_compilation/test143.d(19): Deprecation: `imports.test143.x` is not visible from module `test143` +fail_compilation/test143.d(19): Error: undefined identifier `x`, did you mean variable `x`? --- */ module test143; diff --git a/test/compilable/test15177.d b/test/fail_compilation/test15177.d similarity index 75% rename from test/compilable/test15177.d rename to test/fail_compilation/test15177.d index 8a97272b6954..e6ce3b5bf11f 100644 --- a/test/compilable/test15177.d +++ b/test/fail_compilation/test15177.d @@ -4,8 +4,8 @@ /* TEST_OUTPUT: --- -compilable/test15177.d-mixin-20(20): Deprecation: `imports.test15117a.object` is not visible from module `test15177` -compilable/test15177.d-mixin-20(20): Deprecation: `imports.test15117a.object` is not visible from module `test15177` +fail_compilation/test15177.d-mixin-20(20): Error: `imports.test15117a.object` is not visible from module `test15177` +fail_compilation/test15177.d(29): Error: template instance `test15177.RunApiTest!()` error instantiating --- */ diff --git a/test/fail_compilation/test15785.d b/test/fail_compilation/test15785.d index 25a302f0fef0..f02d77dffb62 100644 --- a/test/fail_compilation/test15785.d +++ b/test/fail_compilation/test15785.d @@ -2,12 +2,12 @@ /* TEST_OUTPUT: --- -fail_compilation/test15785.d(17): Deprecation: `imports.test15785.Base.foo` is not visible from module `test15785` -fail_compilation/test15785.d(17): Error: class `test15785.Derived` member `foo` is not accessible -fail_compilation/test15785.d(18): Deprecation: `imports.test15785.Base.bar` is not visible from module `test15785` -fail_compilation/test15785.d(18): Error: class `test15785.Derived` member `bar` is not accessible +fail_compilation/test15785.d(17): Error: `imports.test15785.Base.foo` is not visible from module `test15785` +fail_compilation/test15785.d(17): Error: no property `foo` for type `imports.test15785.Base`, did you mean `imports.test15785.Base.foo`? +fail_compilation/test15785.d(18): Error: undefined identifier `bar`, did you mean function `bar`? --- */ + import imports.test15785; class Derived : Base diff --git a/test/fail_compilation/test15785b.d b/test/fail_compilation/test15785b.d index 2531945a9432..52e917047c85 100644 --- a/test/fail_compilation/test15785b.d +++ b/test/fail_compilation/test15785b.d @@ -1,11 +1,11 @@ -// REQUIRED_ARGS: -de +// REQUIRED_ARGS: // PERMUTE_ARGS: /* TEST_OUTPUT: --- -fail_compilation/test15785b.d(15): Deprecation: `imports.test15785.Base.T` is not visible from module `test15785b` -fail_compilation/test15785b.d(16): Deprecation: `imports.test15785.Base.T` is not visible from module `test15785b` -fail_compilation/test15785b.d(17): Deprecation: `imports.test15785.IBase2.T` is not visible from module `test15785b` +fail_compilation/test15785b.d(15): Error: `imports.test15785.Base.T` is not visible from module `test15785b` +fail_compilation/test15785b.d(16): Error: `imports.test15785.Base.T` is not visible from module `test15785b` +fail_compilation/test15785b.d(17): Error: `imports.test15785.IBase2.T` is not visible from module `test15785b` --- */ import imports.test15785; diff --git a/test/fail_compilation/test15925.d b/test/fail_compilation/test15925.d new file mode 100644 index 000000000000..9359859e6fea --- /dev/null +++ b/test/fail_compilation/test15925.d @@ -0,0 +1,19 @@ +/* REQUIRED_ARGS: +PERMUTE_ARGS: +TEST_OUTPUT: +--- +fail_compilation/test15925.d(18): Error: undefined identifier `X` +fail_compilation/test15925.d(18): while evaluating: `static assert(X == 1)` +--- +*/ + +mixin template Import() +{ + import imports.imp15925; +} + +class Foo +{ + mixin Import!(); + static assert(X == 1); +} diff --git a/test/fail_compilation/test19107.d b/test/fail_compilation/test19107.d new file mode 100644 index 000000000000..c748650b2e41 --- /dev/null +++ b/test/fail_compilation/test19107.d @@ -0,0 +1,21 @@ +// REQUIRED_ARGS: +/* +TEST_OUTPUT: +--- +fail_compilation/test19107.d(20): Error: template `test19107.all` cannot deduce function from argument types `!((c) => c)(string[])`, candidates are: +fail_compilation/test19107.d(14): `test19107.all(alias pred, T)(T t) if (is(typeof(I!pred(t))))` +--- +*/ + +// https://issues.dlang.org/show_bug.cgi?id=19107 + +import imports.test19107b; + +void all(alias pred, T)(T t) + if (is(typeof(I!pred(t)))) +{ } + +void main(string[] args) +{ + args.all!(c => c); +} diff --git a/test/fail_compilation/test314.d b/test/fail_compilation/test314.d index 9e63126abc83..ab630a5cad2c 100644 --- a/test/fail_compilation/test314.d +++ b/test/fail_compilation/test314.d @@ -1,11 +1,11 @@ /* -REQUIRED_ARGS: -de +REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/test314.d(19): Deprecation: `imports.a314.renamed` is not visible from module `test314` -fail_compilation/test314.d(20): Deprecation: `imports.a314.bug` is not visible from module `test314` -fail_compilation/test314.d(22): Deprecation: `imports.b314.renamedpkg` is not visible from module `test314` -fail_compilation/test314.d(23): Deprecation: `imports.b314.bugpkg` is not visible from module `test314` +fail_compilation/test314.d(19): Error: undefined identifier `renamed`, did you mean import `renamed`? +fail_compilation/test314.d(20): Error: undefined identifier `bug`, did you mean alias `bug`? +fail_compilation/test314.d(22): Error: undefined identifier `renamedpkg`, did you mean import `renamedpkg`? +fail_compilation/test314.d(23): Error: undefined identifier `bugpkg`, did you mean alias `bugpkg`? --- */ From 458b381fd892c35d2be16cc10b7c62e17285a93c Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 09:08:07 +0900 Subject: [PATCH 02/25] Consolidate compilable/checkimport tests --- test/compilable/checkimports1.d | 15 +++++++++++++++ test/compilable/checkimports1a.d | 19 ------------------- test/compilable/checkimports1b.d | 18 ------------------ test/compilable/checkimports1c.d | 18 ------------------ 4 files changed, 15 insertions(+), 55 deletions(-) create mode 100644 test/compilable/checkimports1.d delete mode 100644 test/compilable/checkimports1a.d delete mode 100644 test/compilable/checkimports1b.d delete mode 100644 test/compilable/checkimports1c.d diff --git a/test/compilable/checkimports1.d b/test/compilable/checkimports1.d new file mode 100644 index 000000000000..9daaf9114799 --- /dev/null +++ b/test/compilable/checkimports1.d @@ -0,0 +1,15 @@ +// This test was first created to verify -transition=checkimiports and -revert=import compiler flags +// After they were deprecated this test passed due to the `lines` being local to `C`. +// `imports.diag12598a` contains a `public struct lines { }`, but the lookup resolution prefers the +// local `string[] lines` and therefore compiles. + +class C +{ + void f() + { + import imports.diag12598a; + lines ~= ""; + } + + string[] lines; +} diff --git a/test/compilable/checkimports1a.d b/test/compilable/checkimports1a.d deleted file mode 100644 index 7f18418fc09d..000000000000 --- a/test/compilable/checkimports1a.d +++ /dev/null @@ -1,19 +0,0 @@ -// REQUIRED_ARGS: -/* -TEST_OUTPUT: ---- ---- -*/ - - -// new lookup + information -class C -{ - void f() - { - import imports.diag12598a; - lines ~= ""; - } - - string[] lines; -} diff --git a/test/compilable/checkimports1b.d b/test/compilable/checkimports1b.d deleted file mode 100644 index 742bd0b3f244..000000000000 --- a/test/compilable/checkimports1b.d +++ /dev/null @@ -1,18 +0,0 @@ -// REQUIRED_ARGS: -/* -TEST_OUTPUT: ---- ---- -*/ - -// old lookup + information -class C -{ - void f() - { - import imports.diag12598a; - lines ~= ""; - } - - string[] lines; -} diff --git a/test/compilable/checkimports1c.d b/test/compilable/checkimports1c.d deleted file mode 100644 index 93555ae6de23..000000000000 --- a/test/compilable/checkimports1c.d +++ /dev/null @@ -1,18 +0,0 @@ -// REQUIRED_ARGS: -/* -TEST_OUTPUT: ---- ---- -*/ - -// old lookup + information (the order of switches is reverse) -class C -{ - void f() - { - import imports.diag12598a; - lines ~= ""; - } - - string[] lines; -} From 625c75a1b3a620ac884e89be778e2528f66f2d47 Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 10:38:49 +0900 Subject: [PATCH 03/25] Add deprecation notice for -transition=checkimports and -revert=import compiler flags --- src/dmd/cli.d | 10 ++++++++-- src/dmd/globals.d | 4 ++-- src/dmd/mars.d | 12 ++++++++++-- test/compilable/testcheckimports.d | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/dmd/cli.d b/src/dmd/cli.d index 7234816cd3c3..d0d6668f8882 100644 --- a/src/dmd/cli.d +++ b/src/dmd/cli.d @@ -671,10 +671,14 @@ dmd -cov -unittest myprog.d /// Representation of a CLI feature struct Feature { + /// Whether or not the feature is still in use + enum Deprecated { no, yes} + string name; /// name of the feature string paramName; // internal transition parameter name string helpText; // detailed description of the feature bool documented = true; // whether this option should be shown in the documentation + bool deprecated_; /// whether the feature is still in use } /// Returns all available transitions @@ -682,7 +686,7 @@ dmd -cov -unittest myprog.d Feature("field", "vfield", "list all non-mutable fields which occupy an object instance"), Feature("checkimports", "check10378", - "give deprecation messages about 10378 anomalies"), + "give deprecation messages about 10378 anomalies", true, Feature.Deprecated.yes), Feature("complex", "vcomplex", "give deprecation messages about all usages of complex or imaginary types"), Feature("tls", "vtls", @@ -694,7 +698,7 @@ dmd -cov -unittest myprog.d /// Returns all available reverts static immutable reverts = [ Feature("dip25", "noDIP25", "revert DIP25 changes https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md"), - Feature("import", "bug10378", "revert to single phase name lookup"), + Feature("import", "bug10378", "revert to single phase name lookup", true, Feature.Deprecated.yes), ]; /// Returns all available previews @@ -777,6 +781,8 @@ struct CLIUsage "list information on all " ~ description)] ~ features; foreach (t; allTransitions) { + if (t.deprecated_ == Usage.Feature.Deprecated.yes) + continue; if (!t.documented) continue; buf ~= " ="; diff --git a/src/dmd/globals.d b/src/dmd/globals.d index 655782eda2db..19575caff9ee 100644 --- a/src/dmd/globals.d +++ b/src/dmd/globals.d @@ -153,8 +153,8 @@ struct Param bool betterC; // be a "better C" compiler; no dependency on D runtime bool addMain; // add a default main() function bool allInst; // generate code for all template instantiations - bool check10378; // check for issues transitioning to 10738 - bool bug10378; // use pre- https://issues.dlang.org/show_bug.cgi?id=10378 search strategy + bool check10378; // check for issues transitioning to 10738 @@@DEPRECATED@@@ Remove in 2010-05 or later + bool bug10378; // use pre- https://issues.dlang.org/show_bug.cgi?id=10378 search strategy @@@DEPRECATED@@@ Remove in 2010-05 or later bool fix16997; // fix integral promotions for unary + - ~ operators // https://issues.dlang.org/show_bug.cgi?id=16997 bool fixAliasThis; // if the current scope has an alias this, check it before searching upper scopes diff --git a/src/dmd/mars.d b/src/dmd/mars.d index 81f5231b7d77..0833b0532d6b 100644 --- a/src/dmd/mars.d +++ b/src/dmd/mars.d @@ -1524,12 +1524,20 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param import dmd.cli : Usage; string buf = `case "all":`; foreach (t; features) + { + if (t.deprecated_ == Usage.Feature.Deprecated.yes) + continue; + buf ~= `params.`~t.paramName~` = true;`; - buf ~= "break;"; + } + buf ~= "break;\n"; foreach (t; features) { - buf ~= `case "`~t.name~`": params.`~t.paramName~` = true; return true;`; + buf ~= `case "`~t.name~`":`; + if (t.deprecated_ == Usage.Feature.Deprecated.yes) + buf ~= "deprecation(Loc.initial, \"`-"~name~"="~t.name~"` no longer has any effect.\"); "; + buf ~= `params.`~t.paramName~` = true; return true;`; } return buf; } diff --git a/test/compilable/testcheckimports.d b/test/compilable/testcheckimports.d index 328b8a9825b1..521b8303cfd2 100644 --- a/test/compilable/testcheckimports.d +++ b/test/compilable/testcheckimports.d @@ -1,4 +1,4 @@ -// REQUIRED_ARGS: -transition=checkimports -de +// REQUIRED_ARGS: /* TEST_OUTPUT: --- From 5425fb0b1261dd2759f19a108304acb48ddaab64 Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 10:59:04 +0900 Subject: [PATCH 04/25] Consolidate fail_compilation/checkimports2x.d tests --- test/fail_compilation/checkimports2.d | 30 ++++++++++++++++++++++++ test/fail_compilation/checkimports2a.d | 32 -------------------------- test/fail_compilation/checkimports2b.d | 29 ----------------------- test/fail_compilation/checkimports2c.d | 29 ----------------------- 4 files changed, 30 insertions(+), 90 deletions(-) create mode 100644 test/fail_compilation/checkimports2.d delete mode 100644 test/fail_compilation/checkimports2a.d delete mode 100644 test/fail_compilation/checkimports2b.d delete mode 100644 test/fail_compilation/checkimports2c.d diff --git a/test/fail_compilation/checkimports2.d b/test/fail_compilation/checkimports2.d new file mode 100644 index 000000000000..36146745e478 --- /dev/null +++ b/test/fail_compilation/checkimports2.d @@ -0,0 +1,30 @@ +// REQUIRED_ARGS: +/* +TEST_OUTPUT: +--- +fail_compilation/checkimports2.d(25): Error: no property `X` for type `checkimports2.B`, did you mean `imports.imp2.X`? +fail_compilation/checkimports2.d(25): while evaluating: `static assert((B).X == 0)` +fail_compilation/checkimports2.d(26): Error: no property `Y` for type `checkimports2.B`, did you mean `imports.imp2.Y`? +fail_compilation/checkimports2.d(26): while evaluating: `static assert((B).Y == 2)` +--- +*/ + +import imports.imp1; + +enum X = 0; + +class B +{ + import imports.imp2; + static assert(X == 0); // imp2.X --> .X + int[Y] aa; // imp2.Y +} + +class C : B +{ + static assert(B.X == 0); // imp2.X --> error + static assert(B.Y == 2); // imp2.Y --> error + + static assert(X == 0); // imp2.X --> .X + static assert(Y == 1); // imp2.Y --> imp1.Y +} diff --git a/test/fail_compilation/checkimports2a.d b/test/fail_compilation/checkimports2a.d deleted file mode 100644 index abec4242eeca..000000000000 --- a/test/fail_compilation/checkimports2a.d +++ /dev/null @@ -1,32 +0,0 @@ -// REQUIRED_ARGS: -/* -TEST_OUTPUT: ---- -fail_compilation/checkimports2a.d(27): Error: no property `X` for type `checkimports2a.B`, did you mean `imports.imp2.X`? -fail_compilation/checkimports2a.d(27): while evaluating: `static assert((B).X == 0)` -fail_compilation/checkimports2a.d(28): Error: no property `Y` for type `checkimports2a.B`, did you mean `imports.imp2.Y`? -fail_compilation/checkimports2a.d(28): while evaluating: `static assert((B).Y == 2)` ---- -*/ - -// new lookup + information - -import imports.imp1; - -enum X = 0; - -class B -{ - import imports.imp2; - static assert(X == 0); // imp2.X --> .X - int[Y] aa; // imp2.Y -} - -class C : B -{ - static assert(B.X == 0); // imp2.X --> error - static assert(B.Y == 2); // imp2.Y --> error - - static assert(X == 0); // imp2.X --> .X - static assert(Y == 1); // imp2.Y --> imp1.Y -} diff --git a/test/fail_compilation/checkimports2b.d b/test/fail_compilation/checkimports2b.d deleted file mode 100644 index 8b99fdc54058..000000000000 --- a/test/fail_compilation/checkimports2b.d +++ /dev/null @@ -1,29 +0,0 @@ -// REQUIRED_ARGS: -/* -TEST_OUTPUT: ---- -fail_compilation/checkimports2b.d(18): Error: static assert: `0 == 2` is false ---- -*/ - -// old lookup + information - -import imports.imp1; - -enum X = 0; - -class B -{ - import imports.imp2; - static assert(X == 2); // imp2.X --> .X (information) - int[Y] aa; // imp2.Y -} - -class C : B -{ - static assert(B.X == 2); // imp2.X --> error (keep old lookup rule) - static assert(B.Y == 2); // imp2.Y --> error (keep old lookup rule) - - static assert(X == 2); // imp2.X --> .X (information) - static assert(Y == 2); // imp2.Y --> imp1.Y (information) -} diff --git a/test/fail_compilation/checkimports2c.d b/test/fail_compilation/checkimports2c.d deleted file mode 100644 index 4208dcdf6b2a..000000000000 --- a/test/fail_compilation/checkimports2c.d +++ /dev/null @@ -1,29 +0,0 @@ -// REQUIRED_ARGS: -/* -TEST_OUTPUT: ---- -fail_compilation/checkimports2c.d(18): Error: static assert: `0 == 2` is false ---- -*/ - -// old lookup + information (the order of switches is reverse) - -import imports.imp1; - -enum X = 0; - -class B -{ - import imports.imp2; - static assert(X == 2); // imp2.X --> .X (information) - int[Y] aa; // imp2.Y -} - -class C : B -{ - static assert(B.X == 2); // imp2.X --> error (keep old lookup rule) - static assert(B.Y == 2); // imp2.Y --> error (keep old lookup rule) - - static assert(X == 2); // imp2.X --> .X (information) - static assert(Y == 2); // imp2.Y --> imp1.Y (information) -} From 8de197d17aae54fd5d4b2522f2b4970ea1d6e5dd Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 11:34:28 +0900 Subject: [PATCH 05/25] Add URL for DIP22 to compilable/dip22.d --- test/compilable/dip22d.d | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/compilable/dip22d.d b/test/compilable/dip22d.d index e8f26655a8ea..1becf0c4c7e7 100644 --- a/test/compilable/dip22d.d +++ b/test/compilable/dip22d.d @@ -1,9 +1,9 @@ /* REQUIRED_ARGS: -TEST_OUTPUT: ---- ---- */ + +// https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP22.md + import imports.dip22d; import imports.dip22e; From b7f2e634fc5d24b4a7eee5d69d57a5edff7c7d37 Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 13:53:12 +0900 Subject: [PATCH 06/25] Remove some redundant 'not visible from module' errors --- src/dmd/typesem.d | 1 - test/fail_compilation/diag10169.d | 3 +-- test/fail_compilation/diag5385.d | 28 ++++++++++++---------------- test/fail_compilation/dip22a.d | 17 ++++++++--------- test/fail_compilation/fail10528.d | 23 +++++++++++------------ test/fail_compilation/fail18979.d | 3 +-- 6 files changed, 33 insertions(+), 42 deletions(-) diff --git a/src/dmd/typesem.d b/src/dmd/typesem.d index e793c7b08607..dfccfa50705b 100644 --- a/src/dmd/typesem.d +++ b/src/dmd/typesem.d @@ -3446,7 +3446,6 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag) } if (!(sc.flags & SCOPE.ignoresymbolvisibility) && !symbolIsVisible(sc, s)) { - .error(e.loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toPrettyChars()); return noMember(mt, sc, e, ident, flag); } if (!s.isFuncDeclaration()) // because of overloading diff --git a/test/fail_compilation/diag10169.d b/test/fail_compilation/diag10169.d index 3b20b562aca9..3c35b66c045f 100644 --- a/test/fail_compilation/diag10169.d +++ b/test/fail_compilation/diag10169.d @@ -1,8 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/diag10169.d(12): Error: `imports.a10169.B.x` is not visible from module `diag10169` -fail_compilation/diag10169.d(12): Error: no property `x` for type `B`, did you mean `imports.a10169.B.x`? +fail_compilation/diag10169.d(11): Error: no property `x` for type `B`, did you mean `imports.a10169.B.x`? --- */ import imports.a10169; diff --git a/test/fail_compilation/diag5385.d b/test/fail_compilation/diag5385.d index 5e4aa4271579..9199421570ba 100644 --- a/test/fail_compilation/diag5385.d +++ b/test/fail_compilation/diag5385.d @@ -1,22 +1,18 @@ /* TEST_OUTPUT: --- -fail_compilation/diag5385.d(27): Error: `imports.fail5385.C.privX` is not visible from module `diag5385` -fail_compilation/diag5385.d(27): Error: no property `privX` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.privX`? -fail_compilation/diag5385.d(28): Error: `imports.fail5385.C.packX` is not visible from module `diag5385` -fail_compilation/diag5385.d(28): Error: no property `packX` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.packX`? -fail_compilation/diag5385.d(29): Error: `imports.fail5385.C.privX2` is not visible from module `diag5385` -fail_compilation/diag5385.d(29): Error: no property `privX2` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.privX2`? -fail_compilation/diag5385.d(30): Error: `imports.fail5385.C.packX2` is not visible from module `diag5385` -fail_compilation/diag5385.d(30): Error: no property `packX2` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.packX2`? -fail_compilation/diag5385.d(31): Error: `imports.fail5385.S.privX` is not visible from module `diag5385` -fail_compilation/diag5385.d(31): Error: no property `privX` for type `S`, did you mean `imports.fail5385.S.privX`? -fail_compilation/diag5385.d(32): Error: `imports.fail5385.S.packX` is not visible from module `diag5385` -fail_compilation/diag5385.d(32): Error: no property `packX` for type `S`, did you mean `imports.fail5385.S.packX`? -fail_compilation/diag5385.d(33): Error: `imports.fail5385.S.privX2` is not visible from module `diag5385` -fail_compilation/diag5385.d(33): Error: no property `privX2` for type `S`, did you mean `imports.fail5385.S.privX2`? -fail_compilation/diag5385.d(34): Error: `imports.fail5385.S.packX2` is not visible from module `diag5385` -fail_compilation/diag5385.d(34): Error: no property `packX2` for type `S`, did you mean `imports.fail5385.S.packX2`? +fail_compilation/diag5385.d(23): Error: `imports.fail5385.C.privX` is not visible from module `diag5385` +fail_compilation/diag5385.d(23): Error: no property `privX` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.privX`? +fail_compilation/diag5385.d(24): Error: `imports.fail5385.C.packX` is not visible from module `diag5385` +fail_compilation/diag5385.d(24): Error: no property `packX` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.packX`? +fail_compilation/diag5385.d(25): Error: `imports.fail5385.C.privX2` is not visible from module `diag5385` +fail_compilation/diag5385.d(25): Error: no property `privX2` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.privX2`? +fail_compilation/diag5385.d(26): Error: `imports.fail5385.C.packX2` is not visible from module `diag5385` +fail_compilation/diag5385.d(26): Error: no property `packX2` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.packX2`? +fail_compilation/diag5385.d(27): Error: no property `privX` for type `S`, did you mean `imports.fail5385.S.privX`? +fail_compilation/diag5385.d(28): Error: no property `packX` for type `S`, did you mean `imports.fail5385.S.packX`? +fail_compilation/diag5385.d(29): Error: no property `privX2` for type `S`, did you mean `imports.fail5385.S.privX2`? +fail_compilation/diag5385.d(30): Error: no property `packX2` for type `S`, did you mean `imports.fail5385.S.packX2`? --- */ diff --git a/test/fail_compilation/dip22a.d b/test/fail_compilation/dip22a.d index b5daabb119dd..933dac1083cc 100644 --- a/test/fail_compilation/dip22a.d +++ b/test/fail_compilation/dip22a.d @@ -2,15 +2,14 @@ REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/dip22a.d(20): Error: `imports.dip22a.Klass.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(20): Error: no property `bar` for type `imports.dip22a.Klass`, did you mean `imports.dip22a.Klass.bar`? -fail_compilation/dip22a.d(21): Error: `imports.dip22a.Struct.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(21): Error: no property `bar` for type `Struct`, did you mean `imports.dip22a.Struct.bar`? -fail_compilation/dip22a.d(22): Error: `imports.dip22a.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(22): Error: undefined identifier `bar` in module `imports.dip22a`, did you mean function `bar`? -fail_compilation/dip22a.d(23): Error: `imports.dip22a.Template!int.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(23): Error: no property `bar` for type `void` -fail_compilation/dip22a.d(24): Error: no property `bar` for type `int` +fail_compilation/dip22a.d(19): Error: `imports.dip22a.Klass.bar` is not visible from module `dip22a` +fail_compilation/dip22a.d(19): Error: no property `bar` for type `imports.dip22a.Klass`, did you mean `imports.dip22a.Klass.bar`? +fail_compilation/dip22a.d(20): Error: no property `bar` for type `Struct`, did you mean `imports.dip22a.Struct.bar`? +fail_compilation/dip22a.d(21): Error: `imports.dip22a.bar` is not visible from module `dip22a` +fail_compilation/dip22a.d(21): Error: undefined identifier `bar` in module `imports.dip22a`, did you mean function `bar`? +fail_compilation/dip22a.d(22): Error: `imports.dip22a.Template!int.bar` is not visible from module `dip22a` +fail_compilation/dip22a.d(22): Error: no property `bar` for type `void` +fail_compilation/dip22a.d(23): Error: no property `bar` for type `int` --- */ import imports.dip22a; diff --git a/test/fail_compilation/fail10528.d b/test/fail_compilation/fail10528.d index 1806828cdf0d..af5f6beecfe0 100644 --- a/test/fail_compilation/fail10528.d +++ b/test/fail_compilation/fail10528.d @@ -1,18 +1,17 @@ /* TEST_OUTPUT: --- -fail_compilation/fail10528.d(23): Error: undefined identifier `a`, did you mean variable `a`? -fail_compilation/fail10528.d(24): Error: `a10528.a` is not visible from module `fail10528` -fail_compilation/fail10528.d(24): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? -fail_compilation/fail10528.d(26): Error: undefined identifier `b`, did you mean enum member `b`? -fail_compilation/fail10528.d(27): Error: `a10528.b` is not visible from module `fail10528` -fail_compilation/fail10528.d(27): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? -fail_compilation/fail10528.d(29): Error: `a10528.S.c` is not visible from module `fail10528` -fail_compilation/fail10528.d(29): Error: no property `c` for type `S`, did you mean `a10528.S.c`? -fail_compilation/fail10528.d(30): Error: variable `a10528.S.c` is not accessible from module `fail10528` -fail_compilation/fail10528.d(32): Error: `a10528.C.d` is not visible from module `fail10528` -fail_compilation/fail10528.d(32): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? -fail_compilation/fail10528.d(33): Error: variable `a10528.C.d` is not accessible from module `fail10528` +fail_compilation/fail10528.d(22): Error: undefined identifier `a`, did you mean variable `a`? +fail_compilation/fail10528.d(23): Error: `a10528.a` is not visible from module `fail10528` +fail_compilation/fail10528.d(23): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? +fail_compilation/fail10528.d(25): Error: undefined identifier `b`, did you mean enum member `b`? +fail_compilation/fail10528.d(26): Error: `a10528.b` is not visible from module `fail10528` +fail_compilation/fail10528.d(26): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? +fail_compilation/fail10528.d(28): Error: no property `c` for type `S`, did you mean `a10528.S.c`? +fail_compilation/fail10528.d(29): Error: variable `a10528.S.c` is not accessible from module `fail10528` +fail_compilation/fail10528.d(31): Error: `a10528.C.d` is not visible from module `fail10528` +fail_compilation/fail10528.d(31): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? +fail_compilation/fail10528.d(32): Error: variable `a10528.C.d` is not accessible from module `fail10528` --- */ diff --git a/test/fail_compilation/fail18979.d b/test/fail_compilation/fail18979.d index e30f2242948d..87fd330d2c74 100644 --- a/test/fail_compilation/fail18979.d +++ b/test/fail_compilation/fail18979.d @@ -2,8 +2,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail18979.d(14): Error: `imports.imp18979.Foo.__ctor(A)(A a)` is not visible from module `fail18979` -fail_compilation/fail18979.d(14): Error: no property `__ctor` for type `Foo`, did you mean `imports.imp18979.Foo.__ctor(A)(A a)`? +fail_compilation/fail18979.d(13): Error: no property `__ctor` for type `Foo`, did you mean `imports.imp18979.Foo.__ctor(A)(A a)`? ---- */ From 8e9b2cae2e957d95a1a47de89ba8e4227ac12132 Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 15:24:43 +0900 Subject: [PATCH 07/25] Remove some redundant access check failures --- src/dmd/access.d | 7 ++----- test/fail_compilation/fail10528.d | 20 +++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/dmd/access.d b/src/dmd/access.d index 7f7c5dbd1a25..1cbefe23d52d 100644 --- a/src/dmd/access.d +++ b/src/dmd/access.d @@ -406,11 +406,8 @@ bool checkAccess(Loc loc, Scope* sc, Expression e, Declaration d) } if (!e) { - if (d.prot().kind == Prot.Kind.private_ && d.getAccessModule() != sc._module || d.prot().kind == Prot.Kind.package_ && !hasPackageAccess(sc, d)) - { - error(loc, "%s `%s` is not accessible from module `%s`", d.kind(), d.toPrettyChars(), sc._module.toChars()); - return true; - } + // Access have been removed in favor of visibility checks. + // See https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP22.md } else if (e.type.ty == Tclass) { diff --git a/test/fail_compilation/fail10528.d b/test/fail_compilation/fail10528.d index af5f6beecfe0..bbf7c6bf337e 100644 --- a/test/fail_compilation/fail10528.d +++ b/test/fail_compilation/fail10528.d @@ -1,17 +1,15 @@ /* TEST_OUTPUT: --- -fail_compilation/fail10528.d(22): Error: undefined identifier `a`, did you mean variable `a`? -fail_compilation/fail10528.d(23): Error: `a10528.a` is not visible from module `fail10528` -fail_compilation/fail10528.d(23): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? -fail_compilation/fail10528.d(25): Error: undefined identifier `b`, did you mean enum member `b`? -fail_compilation/fail10528.d(26): Error: `a10528.b` is not visible from module `fail10528` -fail_compilation/fail10528.d(26): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? -fail_compilation/fail10528.d(28): Error: no property `c` for type `S`, did you mean `a10528.S.c`? -fail_compilation/fail10528.d(29): Error: variable `a10528.S.c` is not accessible from module `fail10528` -fail_compilation/fail10528.d(31): Error: `a10528.C.d` is not visible from module `fail10528` -fail_compilation/fail10528.d(31): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? -fail_compilation/fail10528.d(32): Error: variable `a10528.C.d` is not accessible from module `fail10528` +fail_compilation/fail10528.d(20): Error: undefined identifier `a`, did you mean variable `a`? +fail_compilation/fail10528.d(21): Error: `a10528.a` is not visible from module `fail10528` +fail_compilation/fail10528.d(21): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? +fail_compilation/fail10528.d(23): Error: undefined identifier `b`, did you mean enum member `b`? +fail_compilation/fail10528.d(24): Error: `a10528.b` is not visible from module `fail10528` +fail_compilation/fail10528.d(24): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? +fail_compilation/fail10528.d(26): Error: no property `c` for type `S`, did you mean `a10528.S.c`? +fail_compilation/fail10528.d(29): Error: `a10528.C.d` is not visible from module `fail10528` +fail_compilation/fail10528.d(29): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? --- */ From 65a62220fd6da125c81ff22f711ba50db9d4492e Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 16:11:42 +0900 Subject: [PATCH 08/25] Remove some more redundant 'not visible from module' errors --- src/dmd/expressionsem.d | 1 - test/fail_compilation/dip22a.d | 14 ++++++-------- test/fail_compilation/fail10528.d | 16 +++++++--------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/dmd/expressionsem.d b/src/dmd/expressionsem.d index e0db1203c398..c7aaae461226 100644 --- a/src/dmd/expressionsem.d +++ b/src/dmd/expressionsem.d @@ -10994,7 +10994,6 @@ Expression semanticY(DotIdExp exp, Scope* sc, int flag) */ if (s && !(sc.flags & SCOPE.ignoresymbolvisibility) && !symbolIsVisible(sc._module, s)) { - error(exp.loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toChars()); s = null; } if (s) diff --git a/test/fail_compilation/dip22a.d b/test/fail_compilation/dip22a.d index 933dac1083cc..77db6253fa29 100644 --- a/test/fail_compilation/dip22a.d +++ b/test/fail_compilation/dip22a.d @@ -2,14 +2,12 @@ REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/dip22a.d(19): Error: `imports.dip22a.Klass.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(19): Error: no property `bar` for type `imports.dip22a.Klass`, did you mean `imports.dip22a.Klass.bar`? -fail_compilation/dip22a.d(20): Error: no property `bar` for type `Struct`, did you mean `imports.dip22a.Struct.bar`? -fail_compilation/dip22a.d(21): Error: `imports.dip22a.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(21): Error: undefined identifier `bar` in module `imports.dip22a`, did you mean function `bar`? -fail_compilation/dip22a.d(22): Error: `imports.dip22a.Template!int.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(22): Error: no property `bar` for type `void` -fail_compilation/dip22a.d(23): Error: no property `bar` for type `int` +fail_compilation/dip22a.d(17): Error: `imports.dip22a.Klass.bar` is not visible from module `dip22a` +fail_compilation/dip22a.d(17): Error: no property `bar` for type `imports.dip22a.Klass`, did you mean `imports.dip22a.Klass.bar`? +fail_compilation/dip22a.d(18): Error: no property `bar` for type `Struct`, did you mean `imports.dip22a.Struct.bar`? +fail_compilation/dip22a.d(19): Error: undefined identifier `bar` in module `imports.dip22a`, did you mean function `bar`? +fail_compilation/dip22a.d(20): Error: no property `bar` for type `void` +fail_compilation/dip22a.d(21): Error: no property `bar` for type `int` --- */ import imports.dip22a; diff --git a/test/fail_compilation/fail10528.d b/test/fail_compilation/fail10528.d index bbf7c6bf337e..3f1e68a6ef32 100644 --- a/test/fail_compilation/fail10528.d +++ b/test/fail_compilation/fail10528.d @@ -1,15 +1,13 @@ /* TEST_OUTPUT: --- -fail_compilation/fail10528.d(20): Error: undefined identifier `a`, did you mean variable `a`? -fail_compilation/fail10528.d(21): Error: `a10528.a` is not visible from module `fail10528` -fail_compilation/fail10528.d(21): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? -fail_compilation/fail10528.d(23): Error: undefined identifier `b`, did you mean enum member `b`? -fail_compilation/fail10528.d(24): Error: `a10528.b` is not visible from module `fail10528` -fail_compilation/fail10528.d(24): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? -fail_compilation/fail10528.d(26): Error: no property `c` for type `S`, did you mean `a10528.S.c`? -fail_compilation/fail10528.d(29): Error: `a10528.C.d` is not visible from module `fail10528` -fail_compilation/fail10528.d(29): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? +fail_compilation/fail10528.d(18): Error: undefined identifier `a`, did you mean variable `a`? +fail_compilation/fail10528.d(19): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? +fail_compilation/fail10528.d(21): Error: undefined identifier `b`, did you mean enum member `b`? +fail_compilation/fail10528.d(22): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? +fail_compilation/fail10528.d(24): Error: no property `c` for type `S`, did you mean `a10528.S.c`? +fail_compilation/fail10528.d(27): Error: `a10528.C.d` is not visible from module `fail10528` +fail_compilation/fail10528.d(27): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? --- */ From 71543d922cafb9a6f32bcccb11ab75870e56f167 Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 16:33:21 +0900 Subject: [PATCH 09/25] Change visibility deprecation to an error in typesem.d --- src/dmd/typesem.d | 2 +- test/fail_compilation/test15897.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dmd/typesem.d b/src/dmd/typesem.d index dfccfa50705b..62fe23839ad9 100644 --- a/src/dmd/typesem.d +++ b/src/dmd/typesem.d @@ -3730,7 +3730,7 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag) { s = mt.sym.search(e.loc, ident, flags | SearchLocalsOnly | IgnoreSymbolVisibility); if (s && !(flags & IgnoreErrors)) - .deprecation(e.loc, "`%s` is not visible from class `%s`", s.toPrettyChars(), mt.sym.toChars()); + .error(e.loc, "`%s` is not visible from class `%s`", s.toPrettyChars(), mt.sym.toChars()); } return s; diff --git a/test/fail_compilation/test15897.d b/test/fail_compilation/test15897.d index f8729519b13c..174d87f321fd 100644 --- a/test/fail_compilation/test15897.d +++ b/test/fail_compilation/test15897.d @@ -2,7 +2,7 @@ /* TEST_OUTPUT: --- -fail_compilation/test15897.d(18): Deprecation: `test15897.Animal.create` is not visible from class `Cat` +fail_compilation/test15897.d(18): Error: `test15897.Animal.create` is not visible from class `Cat` --- */ module test15897; From 20151949c9a4a299828ba52e40c229fa8ca30ddd Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 17:10:50 +0900 Subject: [PATCH 10/25] Remove some more redundant 'not visible from module' errors --- src/dmd/typesem.d | 1 - test/fail_compilation/diag5385.d | 20 ++++++++------------ test/fail_compilation/dip22a.d | 11 +++++------ test/fail_compilation/fail10528.d | 13 ++++++------- test/fail_compilation/test15785.d | 5 ++--- 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/dmd/typesem.d b/src/dmd/typesem.d index 62fe23839ad9..e40f8a65ee77 100644 --- a/src/dmd/typesem.d +++ b/src/dmd/typesem.d @@ -3884,7 +3884,6 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag) } if (!(sc.flags & SCOPE.ignoresymbolvisibility) && !symbolIsVisible(sc, s)) { - .error(e.loc, "`%s` is not visible from module `%s`", s.toPrettyChars(), sc._module.toPrettyChars()); return noMember(mt, sc, e, ident, flag); } if (!s.isFuncDeclaration()) // because of overloading diff --git a/test/fail_compilation/diag5385.d b/test/fail_compilation/diag5385.d index 9199421570ba..7c81b168c70d 100644 --- a/test/fail_compilation/diag5385.d +++ b/test/fail_compilation/diag5385.d @@ -1,18 +1,14 @@ /* TEST_OUTPUT: --- -fail_compilation/diag5385.d(23): Error: `imports.fail5385.C.privX` is not visible from module `diag5385` -fail_compilation/diag5385.d(23): Error: no property `privX` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.privX`? -fail_compilation/diag5385.d(24): Error: `imports.fail5385.C.packX` is not visible from module `diag5385` -fail_compilation/diag5385.d(24): Error: no property `packX` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.packX`? -fail_compilation/diag5385.d(25): Error: `imports.fail5385.C.privX2` is not visible from module `diag5385` -fail_compilation/diag5385.d(25): Error: no property `privX2` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.privX2`? -fail_compilation/diag5385.d(26): Error: `imports.fail5385.C.packX2` is not visible from module `diag5385` -fail_compilation/diag5385.d(26): Error: no property `packX2` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.packX2`? -fail_compilation/diag5385.d(27): Error: no property `privX` for type `S`, did you mean `imports.fail5385.S.privX`? -fail_compilation/diag5385.d(28): Error: no property `packX` for type `S`, did you mean `imports.fail5385.S.packX`? -fail_compilation/diag5385.d(29): Error: no property `privX2` for type `S`, did you mean `imports.fail5385.S.privX2`? -fail_compilation/diag5385.d(30): Error: no property `packX2` for type `S`, did you mean `imports.fail5385.S.packX2`? +fail_compilation/diag5385.d(19): Error: no property `privX` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.privX`? +fail_compilation/diag5385.d(20): Error: no property `packX` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.packX`? +fail_compilation/diag5385.d(21): Error: no property `privX2` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.privX2`? +fail_compilation/diag5385.d(22): Error: no property `packX2` for type `imports.fail5385.C`, did you mean `imports.fail5385.C.packX2`? +fail_compilation/diag5385.d(23): Error: no property `privX` for type `S`, did you mean `imports.fail5385.S.privX`? +fail_compilation/diag5385.d(24): Error: no property `packX` for type `S`, did you mean `imports.fail5385.S.packX`? +fail_compilation/diag5385.d(25): Error: no property `privX2` for type `S`, did you mean `imports.fail5385.S.privX2`? +fail_compilation/diag5385.d(26): Error: no property `packX2` for type `S`, did you mean `imports.fail5385.S.packX2`? --- */ diff --git a/test/fail_compilation/dip22a.d b/test/fail_compilation/dip22a.d index 77db6253fa29..5bd2b5b03047 100644 --- a/test/fail_compilation/dip22a.d +++ b/test/fail_compilation/dip22a.d @@ -2,12 +2,11 @@ REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/dip22a.d(17): Error: `imports.dip22a.Klass.bar` is not visible from module `dip22a` -fail_compilation/dip22a.d(17): Error: no property `bar` for type `imports.dip22a.Klass`, did you mean `imports.dip22a.Klass.bar`? -fail_compilation/dip22a.d(18): Error: no property `bar` for type `Struct`, did you mean `imports.dip22a.Struct.bar`? -fail_compilation/dip22a.d(19): Error: undefined identifier `bar` in module `imports.dip22a`, did you mean function `bar`? -fail_compilation/dip22a.d(20): Error: no property `bar` for type `void` -fail_compilation/dip22a.d(21): Error: no property `bar` for type `int` +fail_compilation/dip22a.d(16): Error: no property `bar` for type `imports.dip22a.Klass`, did you mean `imports.dip22a.Klass.bar`? +fail_compilation/dip22a.d(17): Error: no property `bar` for type `Struct`, did you mean `imports.dip22a.Struct.bar`? +fail_compilation/dip22a.d(18): Error: undefined identifier `bar` in module `imports.dip22a`, did you mean function `bar`? +fail_compilation/dip22a.d(19): Error: no property `bar` for type `void` +fail_compilation/dip22a.d(20): Error: no property `bar` for type `int` --- */ import imports.dip22a; diff --git a/test/fail_compilation/fail10528.d b/test/fail_compilation/fail10528.d index 3f1e68a6ef32..95aa1e23e29d 100644 --- a/test/fail_compilation/fail10528.d +++ b/test/fail_compilation/fail10528.d @@ -1,13 +1,12 @@ /* TEST_OUTPUT: --- -fail_compilation/fail10528.d(18): Error: undefined identifier `a`, did you mean variable `a`? -fail_compilation/fail10528.d(19): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? -fail_compilation/fail10528.d(21): Error: undefined identifier `b`, did you mean enum member `b`? -fail_compilation/fail10528.d(22): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? -fail_compilation/fail10528.d(24): Error: no property `c` for type `S`, did you mean `a10528.S.c`? -fail_compilation/fail10528.d(27): Error: `a10528.C.d` is not visible from module `fail10528` -fail_compilation/fail10528.d(27): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? +fail_compilation/fail10528.d(17): Error: undefined identifier `a`, did you mean variable `a`? +fail_compilation/fail10528.d(18): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? +fail_compilation/fail10528.d(20): Error: undefined identifier `b`, did you mean enum member `b`? +fail_compilation/fail10528.d(21): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? +fail_compilation/fail10528.d(23): Error: no property `c` for type `S`, did you mean `a10528.S.c`? +fail_compilation/fail10528.d(26): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? --- */ diff --git a/test/fail_compilation/test15785.d b/test/fail_compilation/test15785.d index f02d77dffb62..6ac76f9fb966 100644 --- a/test/fail_compilation/test15785.d +++ b/test/fail_compilation/test15785.d @@ -2,9 +2,8 @@ /* TEST_OUTPUT: --- -fail_compilation/test15785.d(17): Error: `imports.test15785.Base.foo` is not visible from module `test15785` -fail_compilation/test15785.d(17): Error: no property `foo` for type `imports.test15785.Base`, did you mean `imports.test15785.Base.foo`? -fail_compilation/test15785.d(18): Error: undefined identifier `bar`, did you mean function `bar`? +fail_compilation/test15785.d(16): Error: no property `foo` for type `imports.test15785.Base`, did you mean `imports.test15785.Base.foo`? +fail_compilation/test15785.d(17): Error: undefined identifier `bar`, did you mean function `bar`? --- */ From 2356a4f19868edcac60a47fcb3edb22d09a1c40d Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 18:00:12 +0900 Subject: [PATCH 11/25] Remove compilable/checkimports1.d as it is a duplicate of compilable/diag12598.d --- test/compilable/checkimports1.d | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 test/compilable/checkimports1.d diff --git a/test/compilable/checkimports1.d b/test/compilable/checkimports1.d deleted file mode 100644 index 9daaf9114799..000000000000 --- a/test/compilable/checkimports1.d +++ /dev/null @@ -1,15 +0,0 @@ -// This test was first created to verify -transition=checkimiports and -revert=import compiler flags -// After they were deprecated this test passed due to the `lines` being local to `C`. -// `imports.diag12598a` contains a `public struct lines { }`, but the lookup resolution prefers the -// local `string[] lines` and therefore compiles. - -class C -{ - void f() - { - import imports.diag12598a; - lines ~= ""; - } - - string[] lines; -} From 1fa740a4e98c42bb6c86d467b7e5b3ad3dc4bd67 Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 18:53:02 +0900 Subject: [PATCH 12/25] Refactor searchSym() in typesem.d --- src/dmd/typesem.d | 29 ++++------------------------- test/fail_compilation/test15897.d | 2 +- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/dmd/typesem.d b/src/dmd/typesem.d index e40f8a65ee77..c5a52bd9560f 100644 --- a/src/dmd/typesem.d +++ b/src/dmd/typesem.d @@ -3429,16 +3429,8 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag) return e; } - Dsymbol searchSym() - { - int flags = sc.flags & SCOPE.ignoresymbolvisibility ? IgnoreSymbolVisibility : 0; - - auto s = mt.sym.search(e.loc, ident, flags | IgnorePrivateImports); - - return s; - } - - s = searchSym(); + immutable flags = sc.flags & SCOPE.ignoresymbolvisibility ? IgnoreSymbolVisibility : 0; + s = mt.sym.search(e.loc, ident, flags | IgnorePrivateImports); L1: if (!s) { @@ -3721,22 +3713,9 @@ Expression dotExp(Type mt, Scope* sc, Expression e, Identifier ident, int flag) return e; } - Dsymbol searchSym() - { - int flags = sc.flags & SCOPE.ignoresymbolvisibility ? IgnoreSymbolVisibility : 0; - - auto s = mt.sym.search(e.loc, ident, flags | SearchLocalsOnly); - if (!s && !(flags & IgnoreSymbolVisibility)) - { - s = mt.sym.search(e.loc, ident, flags | SearchLocalsOnly | IgnoreSymbolVisibility); - if (s && !(flags & IgnoreErrors)) - .error(e.loc, "`%s` is not visible from class `%s`", s.toPrettyChars(), mt.sym.toChars()); - } - - return s; - } + int flags = sc.flags & SCOPE.ignoresymbolvisibility ? IgnoreSymbolVisibility : 0; + s = mt.sym.search(e.loc, ident, flags | IgnorePrivateImports); - s = searchSym(); L1: if (!s) { diff --git a/test/fail_compilation/test15897.d b/test/fail_compilation/test15897.d index 174d87f321fd..33db2167968b 100644 --- a/test/fail_compilation/test15897.d +++ b/test/fail_compilation/test15897.d @@ -2,7 +2,7 @@ /* TEST_OUTPUT: --- -fail_compilation/test15897.d(18): Error: `test15897.Animal.create` is not visible from class `Cat` +fail_compilation/test15897.d(18): Error: no property `create` for type `imports.test15897.Cat`, did you mean `test15897.Animal.create`? --- */ module test15897; From 3fe71f2d5a7ce4b18c73138c868050d9566f52c6 Mon Sep 17 00:00:00 2001 From: JinShil Date: Thu, 18 Apr 2019 22:05:32 +0900 Subject: [PATCH 13/25] Fix access check for with statement --- src/dmd/access.d | 2 +- src/dmd/expressionsem.d | 10 +++++++--- test/fail_compilation/fail10528.d | 14 ++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/dmd/access.d b/src/dmd/access.d index 1cbefe23d52d..da75c617128c 100644 --- a/src/dmd/access.d +++ b/src/dmd/access.d @@ -406,7 +406,7 @@ bool checkAccess(Loc loc, Scope* sc, Expression e, Declaration d) } if (!e) { - // Access have been removed in favor of visibility checks. + // Access checks have been removed in favor of visibility checks. // See https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP22.md } else if (e.type.ty == Tclass) diff --git a/src/dmd/expressionsem.d b/src/dmd/expressionsem.d index c7aaae461226..6ddab6820af5 100644 --- a/src/dmd/expressionsem.d +++ b/src/dmd/expressionsem.d @@ -2414,9 +2414,13 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor { if (withsym) { - Declaration d = s.isDeclaration(); - if (d) - checkAccess(exp.loc, sc, null, d); + if (auto t = withsym.withstate.exp.isTypeExp()) + { + e = new TypeExp(exp.loc, t.type); + e = new DotIdExp(exp.loc, e, exp.ident); + result = e.expressionSemantic(sc); + return; + } } /* If f is really a function template, diff --git a/test/fail_compilation/fail10528.d b/test/fail_compilation/fail10528.d index 95aa1e23e29d..8f278faf29da 100644 --- a/test/fail_compilation/fail10528.d +++ b/test/fail_compilation/fail10528.d @@ -1,12 +1,14 @@ /* TEST_OUTPUT: --- -fail_compilation/fail10528.d(17): Error: undefined identifier `a`, did you mean variable `a`? -fail_compilation/fail10528.d(18): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? -fail_compilation/fail10528.d(20): Error: undefined identifier `b`, did you mean enum member `b`? -fail_compilation/fail10528.d(21): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? -fail_compilation/fail10528.d(23): Error: no property `c` for type `S`, did you mean `a10528.S.c`? -fail_compilation/fail10528.d(26): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? +fail_compilation/fail10528.d(19): Error: undefined identifier `a`, did you mean variable `a`? +fail_compilation/fail10528.d(20): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? +fail_compilation/fail10528.d(22): Error: undefined identifier `b`, did you mean enum member `b`? +fail_compilation/fail10528.d(23): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? +fail_compilation/fail10528.d(25): Error: no property `c` for type `S`, did you mean `a10528.S.c`? +fail_compilation/fail10528.d(26): Error: no property `c` for type `S`, did you mean `a10528.S.c`? +fail_compilation/fail10528.d(28): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? +fail_compilation/fail10528.d(29): Error: no property `d` for type `a10528.C`, did you mean `a10528.C.d`? --- */ From 42d53fe80484693a659f4caafc2bd0cff79e6d6e Mon Sep 17 00:00:00 2001 From: JinShil Date: Fri, 19 Apr 2019 12:54:25 +0900 Subject: [PATCH 14/25] Refactor checkAccess function --- src/dmd/access.d | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/dmd/access.d b/src/dmd/access.d index da75c617128c..8edcb8fb1dc3 100644 --- a/src/dmd/access.d +++ b/src/dmd/access.d @@ -404,12 +404,11 @@ bool checkAccess(Loc loc, Scope* sc, Expression e, Declaration d) // Unittests are always accessible. return false; } + if (!e) - { - // Access checks have been removed in favor of visibility checks. - // See https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP22.md - } - else if (e.type.ty == Tclass) + return false; + + if (e.type.ty == Tclass) { // Do access check ClassDeclaration cd = (cast(TypeClass)e.type).sym; From c583c114f52d89eea036e8971ccb27f337256146 Mon Sep 17 00:00:00 2001 From: JinShil Date: Fri, 19 Apr 2019 15:26:30 +0900 Subject: [PATCH 15/25] Remove suggetions to invisible symbols --- src/dmd/dscope.d | 2 +- src/dmd/dsymbol.d | 2 +- test/fail_compilation/dip22b.d | 2 +- test/fail_compilation/dip22e.d | 2 +- test/fail_compilation/fail10528.d | 4 ++-- test/fail_compilation/fail17625.d | 2 +- test/fail_compilation/fail18938.d | 2 +- test/fail_compilation/fail313.d | 2 +- test/fail_compilation/test143.d | 2 +- test/fail_compilation/test15785.d | 2 +- test/fail_compilation/test15897.d | 2 +- test/fail_compilation/test314.d | 8 ++++---- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/dmd/dscope.d b/src/dmd/dscope.d index e0d2fa5de28d..4972313c711f 100644 --- a/src/dmd/dscope.d +++ b/src/dmd/dscope.d @@ -532,7 +532,7 @@ struct Scope Dsymbol scopesym = null; // search for exact name ignoring visibility first - if (auto s = search(Loc.initial, ident, &scopesym, IgnoreErrors | IgnoreSymbolVisibility)) + if (auto s = search(Loc.initial, ident, &scopesym, IgnoreErrors)) return s; return speller!scope_search_fp(ident.toChars()); } diff --git a/src/dmd/dsymbol.d b/src/dmd/dsymbol.d index 41d7fb2acdb4..fe7b89c173bb 100644 --- a/src/dmd/dsymbol.d +++ b/src/dmd/dsymbol.d @@ -791,7 +791,7 @@ extern (C++) class Dsymbol : ASTNode if (global.gag) return null; // don't do it for speculative compiles; too time consuming // search for exact name ignoring visibility first - if (auto s = search(Loc.initial, ident, IgnoreErrors | IgnoreSymbolVisibility)) + if (auto s = search(Loc.initial, ident, IgnoreErrors)) return s; return speller!symbol_search_fp(ident.toChars()); } diff --git a/test/fail_compilation/dip22b.d b/test/fail_compilation/dip22b.d index 3999f2ae77d7..952018022de6 100644 --- a/test/fail_compilation/dip22b.d +++ b/test/fail_compilation/dip22b.d @@ -2,7 +2,7 @@ REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/dip22b.d(12): Error: undefined identifier `Foo`, did you mean struct `Foo`? +fail_compilation/dip22b.d(12): Error: undefined identifier `Foo`, did you mean variable `foo`? --- */ module pkg.dip22; diff --git a/test/fail_compilation/dip22e.d b/test/fail_compilation/dip22e.d index 81dfbbb63e73..b1411b2f10cd 100644 --- a/test/fail_compilation/dip22e.d +++ b/test/fail_compilation/dip22e.d @@ -2,7 +2,7 @@ REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/dip22e.d(14): Error: undefined identifier `foo`, did you mean function `foo`? +fail_compilation/dip22e.d(14): Error: undefined identifier `foo`, did you mean struct `Foo`? --- */ diff --git a/test/fail_compilation/fail10528.d b/test/fail_compilation/fail10528.d index 8f278faf29da..067e83c035df 100644 --- a/test/fail_compilation/fail10528.d +++ b/test/fail_compilation/fail10528.d @@ -1,9 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/fail10528.d(19): Error: undefined identifier `a`, did you mean variable `a`? +fail_compilation/fail10528.d(19): Error: undefined identifier `a` fail_compilation/fail10528.d(20): Error: undefined identifier `a` in module `a10528`, did you mean variable `a`? -fail_compilation/fail10528.d(22): Error: undefined identifier `b`, did you mean enum member `b`? +fail_compilation/fail10528.d(22): Error: undefined identifier `b` fail_compilation/fail10528.d(23): Error: undefined identifier `b` in module `a10528`, did you mean enum member `b`? fail_compilation/fail10528.d(25): Error: no property `c` for type `S`, did you mean `a10528.S.c`? fail_compilation/fail10528.d(26): Error: no property `c` for type `S`, did you mean `a10528.S.c`? diff --git a/test/fail_compilation/fail17625.d b/test/fail_compilation/fail17625.d index 0689545f59fb..66dd85bd252a 100644 --- a/test/fail_compilation/fail17625.d +++ b/test/fail_compilation/fail17625.d @@ -1,7 +1,7 @@ /* TEST_OUTPUT: --- -fail_compilation/fail17625.d(15): Error: undefined identifier `boo`, did you mean function `boo`? +fail_compilation/fail17625.d(15): Error: undefined identifier `boo` --- */ diff --git a/test/fail_compilation/fail18938.d b/test/fail_compilation/fail18938.d index 671271dc0687..7590d7259ab3 100644 --- a/test/fail_compilation/fail18938.d +++ b/test/fail_compilation/fail18938.d @@ -2,7 +2,7 @@ /* TEST_OUTPUT: --- -fail_compilation/imports/test18938b/file.d(20): Error: undefined identifier `No`, did you mean alias `No`? +fail_compilation/imports/test18938b/file.d(20): Error: undefined identifier `No` --- */ diff --git a/test/fail_compilation/fail313.d b/test/fail_compilation/fail313.d index 0b4bd2a2f056..6a3bc1c798d0 100644 --- a/test/fail_compilation/fail313.d +++ b/test/fail_compilation/fail313.d @@ -2,7 +2,7 @@ TEST_OUTPUT: --- fail_compilation/fail313.d(15): Error: module `imports.b313` is not accessible here, perhaps add `static import imports.b313;` -fail_compilation/fail313.d(22): Error: undefined identifier `core`, did you mean import `core`? +fail_compilation/fail313.d(22): Error: undefined identifier `core` fail_compilation/fail313.d(27): Error: package `imports.pkg313` is not accessible here, perhaps add `static import imports.pkg313;` --- */ diff --git a/test/fail_compilation/test143.d b/test/fail_compilation/test143.d index 2d1192424833..521195b539cc 100644 --- a/test/fail_compilation/test143.d +++ b/test/fail_compilation/test143.d @@ -3,7 +3,7 @@ /* TEST_OUTPUT: --- -fail_compilation/test143.d(19): Error: undefined identifier `x`, did you mean variable `x`? +fail_compilation/test143.d(19): Error: undefined identifier `x` --- */ module test143; diff --git a/test/fail_compilation/test15785.d b/test/fail_compilation/test15785.d index 6ac76f9fb966..474076fd5e44 100644 --- a/test/fail_compilation/test15785.d +++ b/test/fail_compilation/test15785.d @@ -3,7 +3,7 @@ TEST_OUTPUT: --- fail_compilation/test15785.d(16): Error: no property `foo` for type `imports.test15785.Base`, did you mean `imports.test15785.Base.foo`? -fail_compilation/test15785.d(17): Error: undefined identifier `bar`, did you mean function `bar`? +fail_compilation/test15785.d(17): Error: undefined identifier `bar` --- */ diff --git a/test/fail_compilation/test15897.d b/test/fail_compilation/test15897.d index 33db2167968b..aa22c10b76fd 100644 --- a/test/fail_compilation/test15897.d +++ b/test/fail_compilation/test15897.d @@ -2,7 +2,7 @@ /* TEST_OUTPUT: --- -fail_compilation/test15897.d(18): Error: no property `create` for type `imports.test15897.Cat`, did you mean `test15897.Animal.create`? +fail_compilation/test15897.d(18): Error: no property `create` for type `imports.test15897.Cat` --- */ module test15897; diff --git a/test/fail_compilation/test314.d b/test/fail_compilation/test314.d index ab630a5cad2c..eb3f07d378a2 100644 --- a/test/fail_compilation/test314.d +++ b/test/fail_compilation/test314.d @@ -2,10 +2,10 @@ REQUIRED_ARGS: TEST_OUTPUT: --- -fail_compilation/test314.d(19): Error: undefined identifier `renamed`, did you mean import `renamed`? -fail_compilation/test314.d(20): Error: undefined identifier `bug`, did you mean alias `bug`? -fail_compilation/test314.d(22): Error: undefined identifier `renamedpkg`, did you mean import `renamedpkg`? -fail_compilation/test314.d(23): Error: undefined identifier `bugpkg`, did you mean alias `bugpkg`? +fail_compilation/test314.d(19): Error: undefined identifier `renamed` +fail_compilation/test314.d(20): Error: undefined identifier `bug` +fail_compilation/test314.d(22): Error: undefined identifier `renamedpkg` +fail_compilation/test314.d(23): Error: undefined identifier `bugpkg` --- */ From 33ce6c2eaab4eb9160de09829187832478e9f563 Mon Sep 17 00:00:00 2001 From: JinShil Date: Fri, 19 Apr 2019 15:27:37 +0900 Subject: [PATCH 16/25] Remove trailing whitespace in access.d --- src/dmd/access.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dmd/access.d b/src/dmd/access.d index 8edcb8fb1dc3..5f2b75683311 100644 --- a/src/dmd/access.d +++ b/src/dmd/access.d @@ -404,7 +404,7 @@ bool checkAccess(Loc loc, Scope* sc, Expression e, Declaration d) // Unittests are always accessible. return false; } - + if (!e) return false; From 204f83fee39936f49fa8f533d5ecbdb460668bc1 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Fri, 19 Apr 2019 16:06:49 +0900 Subject: [PATCH 17/25] Update src/dmd/cli.d Co-Authored-By: JinShil --- src/dmd/cli.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dmd/cli.d b/src/dmd/cli.d index d0d6668f8882..e55723918e79 100644 --- a/src/dmd/cli.d +++ b/src/dmd/cli.d @@ -678,7 +678,7 @@ dmd -cov -unittest myprog.d string paramName; // internal transition parameter name string helpText; // detailed description of the feature bool documented = true; // whether this option should be shown in the documentation - bool deprecated_; /// whether the feature is still in use + Feature.Deprecated deprecated_; /// whether the feature is still in use } /// Returns all available transitions From 7bf76ef99cc5cdb3297b229a2bde16b96000a831 Mon Sep 17 00:00:00 2001 From: JinShil Date: Fri, 19 Apr 2019 16:51:59 +0900 Subject: [PATCH 18/25] Remove -de flag from fail_compilation/fail18979.d --- test/fail_compilation/fail18979.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fail_compilation/fail18979.d b/test/fail_compilation/fail18979.d index 87fd330d2c74..40ad259019ad 100644 --- a/test/fail_compilation/fail18979.d +++ b/test/fail_compilation/fail18979.d @@ -1,4 +1,4 @@ -// REQUIRED_ARGS: -de +// REQUIRED_ARGS: /* TEST_OUTPUT: --- From aeffe85d3956248f72dbb65d38249d1452b73819 Mon Sep 17 00:00:00 2001 From: JinShil Date: Fri, 19 Apr 2019 16:54:20 +0900 Subject: [PATCH 19/25] Udpate comments for search_correct functions --- src/dmd/dscope.d | 2 +- src/dmd/dsymbol.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dmd/dscope.d b/src/dmd/dscope.d index 4972313c711f..1fc7199cbd20 100644 --- a/src/dmd/dscope.d +++ b/src/dmd/dscope.d @@ -531,7 +531,7 @@ struct Scope } Dsymbol scopesym = null; - // search for exact name ignoring visibility first + // search for exact name first if (auto s = search(Loc.initial, ident, &scopesym, IgnoreErrors)) return s; return speller!scope_search_fp(ident.toChars()); diff --git a/src/dmd/dsymbol.d b/src/dmd/dsymbol.d index fe7b89c173bb..64bab6a0241b 100644 --- a/src/dmd/dsymbol.d +++ b/src/dmd/dsymbol.d @@ -790,7 +790,7 @@ extern (C++) class Dsymbol : ASTNode if (global.gag) return null; // don't do it for speculative compiles; too time consuming - // search for exact name ignoring visibility first + // search for exact name first if (auto s = search(Loc.initial, ident, IgnoreErrors)) return s; return speller!symbol_search_fp(ident.toChars()); From 1f506d7002959655b6d27d909c2654df2dcee247 Mon Sep 17 00:00:00 2001 From: JinShil Date: Fri, 19 Apr 2019 17:03:26 +0900 Subject: [PATCH 20/25] Use simple bool as deprecated flag for features --- src/dmd/cli.d | 11 ++++------- src/dmd/mars.d | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/dmd/cli.d b/src/dmd/cli.d index e55723918e79..0ea3d07438a2 100644 --- a/src/dmd/cli.d +++ b/src/dmd/cli.d @@ -671,14 +671,11 @@ dmd -cov -unittest myprog.d /// Representation of a CLI feature struct Feature { - /// Whether or not the feature is still in use - enum Deprecated { no, yes} - string name; /// name of the feature string paramName; // internal transition parameter name string helpText; // detailed description of the feature bool documented = true; // whether this option should be shown in the documentation - Feature.Deprecated deprecated_; /// whether the feature is still in use + bool deprecated_; /// whether the feature is still in use } /// Returns all available transitions @@ -686,7 +683,7 @@ dmd -cov -unittest myprog.d Feature("field", "vfield", "list all non-mutable fields which occupy an object instance"), Feature("checkimports", "check10378", - "give deprecation messages about 10378 anomalies", true, Feature.Deprecated.yes), + "give deprecation messages about 10378 anomalies", true, true), Feature("complex", "vcomplex", "give deprecation messages about all usages of complex or imaginary types"), Feature("tls", "vtls", @@ -698,7 +695,7 @@ dmd -cov -unittest myprog.d /// Returns all available reverts static immutable reverts = [ Feature("dip25", "noDIP25", "revert DIP25 changes https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md"), - Feature("import", "bug10378", "revert to single phase name lookup", true, Feature.Deprecated.yes), + Feature("import", "bug10378", "revert to single phase name lookup", true, true), ]; /// Returns all available previews @@ -781,7 +778,7 @@ struct CLIUsage "list information on all " ~ description)] ~ features; foreach (t; allTransitions) { - if (t.deprecated_ == Usage.Feature.Deprecated.yes) + if (t.deprecated_) continue; if (!t.documented) continue; diff --git a/src/dmd/mars.d b/src/dmd/mars.d index 0833b0532d6b..cdbea79d7b55 100644 --- a/src/dmd/mars.d +++ b/src/dmd/mars.d @@ -1525,7 +1525,7 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param string buf = `case "all":`; foreach (t; features) { - if (t.deprecated_ == Usage.Feature.Deprecated.yes) + if (t.deprecated_) continue; buf ~= `params.`~t.paramName~` = true;`; @@ -1535,7 +1535,7 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param foreach (t; features) { buf ~= `case "`~t.name~`":`; - if (t.deprecated_ == Usage.Feature.Deprecated.yes) + if (t.deprecated_) buf ~= "deprecation(Loc.initial, \"`-"~name~"="~t.name~"` no longer has any effect.\"); "; buf ~= `params.`~t.paramName~` = true; return true;`; } From 5658ee2a99fccb7bcbe46937787cd5e0eb1432d9 Mon Sep 17 00:00:00 2001 From: JinShil Date: Sat, 20 Apr 2019 15:29:54 +0900 Subject: [PATCH 21/25] Remove some no longer needed code from dsymbol.search --- src/dmd/dsymbol.d | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/dmd/dsymbol.d b/src/dmd/dsymbol.d index 64bab6a0241b..9e4e6639a2d8 100644 --- a/src/dmd/dsymbol.d +++ b/src/dmd/dsymbol.d @@ -1456,7 +1456,7 @@ public: // If private import, don't search it if ((flags & IgnorePrivateImports) && prots[i] == Prot.Kind.private_) continue; - int sflags = flags & (IgnoreErrors | IgnoreAmbiguous | IgnoreSymbolVisibility); // remember these in recursive searches + int sflags = flags & (IgnoreErrors | IgnoreAmbiguous); // remember these in recursive searches Dsymbol ss = (*importedScopes)[i]; //printf("\tscanning import '%s', prots = %d, isModule = %p, isImport = %p\n", ss.toChars(), prots[i], ss.isModule(), ss.isImport()); @@ -1546,18 +1546,6 @@ public: a = mergeOverloadSet(ident, a, s); s = a; } - // TODO: remove once private symbol visibility has been deprecated - if (!(flags & IgnoreErrors) && s.prot().kind == Prot.Kind.private_ && - !s.isOverloadable() && !s.parent.isTemplateMixin() && !s.parent.isNspace()) - { - AliasDeclaration ad = void; - // accessing private selective and renamed imports is - // deprecated by restricting the symbol visibility - if (s.isImport() || (ad = s.isAliasDeclaration()) !is null && ad._import !is null) - {} - else - error(loc, "%s `%s` is `private`", s.kind(), s.toPrettyChars()); - } //printf("\tfound in imports %s.%s\n", toChars(), s.toChars()); return s; } From ae2c4a1f7c2fd7729223f315dd6ea1cfe9eed027 Mon Sep 17 00:00:00 2001 From: JinShil Date: Tue, 23 Apr 2019 14:04:12 +0900 Subject: [PATCH 22/25] Refactor error handling in access.checkAccess --- src/dmd/access.d | 6 +----- src/dmd/expressionsem.d | 18 ++++++++++++++---- test/fail_compilation/fail313.d | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/dmd/access.d b/src/dmd/access.d index 5f2b75683311..83275eed2da0 100644 --- a/src/dmd/access.d +++ b/src/dmd/access.d @@ -451,11 +451,7 @@ bool checkAccess(Loc loc, Scope* sc, Package p) if (sc.scopesym && sc.scopesym.isPackageAccessible(p, Prot(Prot.Kind.private_))) return false; } - auto name = p.toPrettyChars(); - if (p.isPkgMod == PKG.module_ || p.isModule()) - error(loc, "%s `%s` is not accessible here, perhaps add `static import %s;`", p.kind(), name, name); - else - error(loc, "%s `%s` is not accessible here", p.kind(), name); + return true; } diff --git a/src/dmd/expressionsem.d b/src/dmd/expressionsem.d index 6ddab6820af5..92f754b195ab 100644 --- a/src/dmd/expressionsem.d +++ b/src/dmd/expressionsem.d @@ -11002,9 +11002,14 @@ Expression semanticY(DotIdExp exp, Scope* sc, int flag) } if (s) { - if (auto p = s.isPackage()) - checkAccess(exp.loc, sc, p); - + auto p = s.isPackage(); + if (p && checkAccess(exp.loc, sc, p)) + { + s = null; + } + } + if (s) + { // if 's' is a tuple variable, the tuple is returned. s = s.toAlias(); @@ -11178,7 +11183,12 @@ Expression semanticY(DotIdExp exp, Scope* sc, int flag) return null; s = ie.sds.search_correct(exp.ident); if (s) - exp.error("undefined identifier `%s` in %s `%s`, did you mean %s `%s`?", exp.ident.toChars(), ie.sds.kind(), ie.sds.toPrettyChars(), s.kind(), s.toChars()); + { + if (s.isPackage()) + exp.error("undefined identifier `%s` in %s `%s`, perhaps add `static import %s;`", exp.ident.toChars(), ie.sds.kind(), ie.sds.toPrettyChars(), s.toPrettyChars()); + else + exp.error("undefined identifier `%s` in %s `%s`, did you mean %s `%s`?", exp.ident.toChars(), ie.sds.kind(), ie.sds.toPrettyChars(), s.kind(), s.toChars()); + } else exp.error("undefined identifier `%s` in %s `%s`", exp.ident.toChars(), ie.sds.kind(), ie.sds.toPrettyChars()); return new ErrorExp(); diff --git a/test/fail_compilation/fail313.d b/test/fail_compilation/fail313.d index 6a3bc1c798d0..f2e2b07a7014 100644 --- a/test/fail_compilation/fail313.d +++ b/test/fail_compilation/fail313.d @@ -1,9 +1,9 @@ /* TEST_OUTPUT: --- -fail_compilation/fail313.d(15): Error: module `imports.b313` is not accessible here, perhaps add `static import imports.b313;` +fail_compilation/fail313.d(15): Error: undefined identifier `b313` in package `imports`, perhaps add `static import imports.b313;` fail_compilation/fail313.d(22): Error: undefined identifier `core` -fail_compilation/fail313.d(27): Error: package `imports.pkg313` is not accessible here, perhaps add `static import imports.pkg313;` +fail_compilation/fail313.d(27): Error: undefined identifier `pkg313` in package `imports`, perhaps add `static import imports.pkg313;` --- */ module test313; From ffe948cf575ee5bbb7478dfa1aea171831a73573 Mon Sep 17 00:00:00 2001 From: JinShil Date: Wed, 24 Apr 2019 08:49:04 +0900 Subject: [PATCH 23/25] Add changelog for removing visbility deprecation --- changelog/remove_visibility.dd | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/remove_visibility.dd diff --git a/changelog/remove_visibility.dd b/changelog/remove_visibility.dd new file mode 100644 index 000000000000..1392ebbd7778 --- /dev/null +++ b/changelog/remove_visibility.dd @@ -0,0 +1,5 @@ +The deprecation phase for access checks is finished + +The `-transition=import` and `-transition=checkimports` switches no longer have an +effect and are now deprecated. Symbols that are not visible in a particular +scope will no longer be found by the compiler. From 9caf4ec1e6053685b953ceb2d566d3b4ebed327a Mon Sep 17 00:00:00 2001 From: JinShil Date: Wed, 24 Apr 2019 11:43:20 +0900 Subject: [PATCH 24/25] Remove no longer needed code from access.d --- src/dmd/access.d | 232 +---------------------------------------------- 1 file changed, 2 insertions(+), 230 deletions(-) diff --git a/src/dmd/access.d b/src/dmd/access.d index 83275eed2da0..8f9b8521eefc 100644 --- a/src/dmd/access.d +++ b/src/dmd/access.d @@ -28,103 +28,6 @@ import dmd.tokens; private enum LOG = false; -/**************************************** - * Return Prot access for Dsymbol smember in this declaration. - */ -private Prot getAccess(AggregateDeclaration ad, Dsymbol smember) -{ - Prot access_ret = Prot(Prot.Kind.none); - static if (LOG) - { - printf("+AggregateDeclaration::getAccess(this = '%s', smember = '%s')\n", ad.toChars(), smember.toChars()); - } - assert(ad.isStructDeclaration() || ad.isClassDeclaration()); - if (smember.toParent() == ad) - { - access_ret = smember.prot(); - } - else if (smember.isDeclaration().isStatic()) - { - access_ret = smember.prot(); - } - if (ClassDeclaration cd = ad.isClassDeclaration()) - { - foreach (b; *cd.baseclasses) - { - Prot access = getAccess(b.sym, smember); - final switch (access.kind) - { - case Prot.Kind.none: - case Prot.Kind.undefined: - break; - case Prot.Kind.private_: - access_ret = Prot(Prot.Kind.none); // private members of base class not accessible - break; - case Prot.Kind.package_: - case Prot.Kind.protected_: - case Prot.Kind.public_: - case Prot.Kind.export_: - // If access is to be tightened - if (Prot.Kind.public_ < access.kind) - access = Prot(Prot.Kind.public_); - // Pick path with loosest access - if (access_ret.isMoreRestrictiveThan(access)) - access_ret = access; - break; - } - } - } - static if (LOG) - { - printf("-AggregateDeclaration::getAccess(this = '%s', smember = '%s') = %d\n", ad.toChars(), smember.toChars(), access_ret); - } - return access_ret; -} - -/******************************************************** - * Helper function for checkAccess() - * Returns: - * false is not accessible - * true is accessible - */ -private bool isAccessible(Dsymbol smember, Dsymbol sfunc, AggregateDeclaration dthis, AggregateDeclaration cdscope) -{ - assert(dthis); - version (none) - { - printf("isAccessible for %s.%s in function %s() in scope %s\n", dthis.toChars(), smember.toChars(), sfunc ? sfunc.toChars() : "NULL", cdscope ? cdscope.toChars() : "NULL"); - } - if (hasPrivateAccess(dthis, sfunc) || isFriendOf(dthis, cdscope)) - { - if (smember.toParent() == dthis) - return true; - if (ClassDeclaration cdthis = dthis.isClassDeclaration()) - { - foreach (b; *cdthis.baseclasses) - { - const Prot access = getAccess(b.sym, smember); - if (access.kind >= Prot.Kind.protected_ || isAccessible(smember, sfunc, b.sym, cdscope)) - { - return true; - } - } - } - } - else - { - if (smember.toParent() != dthis) - { - if (ClassDeclaration cdthis = dthis.isClassDeclaration()) - { - foreach (b; *cdthis.baseclasses) - if (isAccessible(smember, sfunc, b.sym, cdscope)) - return true; - } - } - } - return false; -} - /******************************* * Do access check for member of this class, this class being the * type of the 'this' pointer used to access smember. @@ -132,59 +35,12 @@ private bool isAccessible(Dsymbol smember, Dsymbol sfunc, AggregateDeclaration d */ bool checkAccess(AggregateDeclaration ad, Loc loc, Scope* sc, Dsymbol smember) { - FuncDeclaration f = sc.func; - AggregateDeclaration cdscope = sc.getStructClassScope(); static if (LOG) { printf("AggregateDeclaration::checkAccess() for %s.%s in function %s() in scope %s\n", ad.toChars(), smember.toChars(), f ? f.toChars() : null, cdscope ? cdscope.toChars() : null); } - Dsymbol smemberparent = smember.toParent(); - if (!smemberparent || !smemberparent.isAggregateDeclaration()) - { - static if (LOG) - { - printf("not an aggregate member\n"); - } - return false; // then it is accessible - } - // BUG: should enable this check - //assert(smember.parent.isBaseOf(this, NULL)); - bool result; - Prot access; - if (smemberparent == ad) - { - access = smember.prot(); - result = access.kind >= Prot.Kind.public_ || hasPrivateAccess(ad, f) || isFriendOf(ad, cdscope) || (access.kind == Prot.Kind.package_ && hasPackageAccess(sc, smember)) || ad.getAccessModule() == sc._module; - static if (LOG) - { - printf("result1 = %d\n", result); - } - } - else if ((access = getAccess(ad, smember)).kind >= Prot.Kind.public_) - { - result = true; - static if (LOG) - { - printf("result2 = %d\n", result); - } - } - else if (access.kind == Prot.Kind.package_ && hasPackageAccess(sc, ad)) - { - result = true; - static if (LOG) - { - printf("result3 = %d\n", result); - } - } - else - { - result = isAccessible(smember, f, ad, cdscope); - static if (LOG) - { - printf("result4 = %d\n", result); - } - } - if (!result && (!(sc.flags & SCOPE.onlysafeaccess) || sc.func.setUnsafe())) + + if (!symbolIsVisible(sc, smember) && (!(sc.flags & SCOPE.onlysafeaccess) || sc.func.setUnsafe())) { ad.error(loc, "member `%s` is not accessible%s", smember.toChars(), (sc.flags & SCOPE.onlysafeaccess) ? " from `@safe` code".ptr : "".ptr); //printf("smember = %s %s, prot = %d, semanticRun = %d\n", @@ -194,34 +50,6 @@ bool checkAccess(AggregateDeclaration ad, Loc loc, Scope* sc, Dsymbol smember) return false; } -/**************************************** - * Determine if this is the same or friend of cd. - */ -private bool isFriendOf(AggregateDeclaration ad, AggregateDeclaration cd) -{ - static if (LOG) - { - printf("AggregateDeclaration::isFriendOf(this = '%s', cd = '%s')\n", ad.toChars(), cd ? cd.toChars() : "null"); - } - if (ad == cd) - return true; - // Friends if both are in the same module - //if (toParent() == cd.toParent()) - if (cd && ad.getAccessModule() == cd.getAccessModule()) - { - static if (LOG) - { - printf("\tin same module\n"); - } - return true; - } - static if (LOG) - { - printf("\tnot friend\n"); - } - return false; -} - /**************************************** * Determine if scope sc has package level access to s. */ @@ -323,62 +151,6 @@ private bool hasProtectedAccess(Scope *sc, Dsymbol s) return sc._module == s.getAccessModule(); } -/********************************** - * Determine if smember has access to private members of this declaration. - */ -private bool hasPrivateAccess(AggregateDeclaration ad, Dsymbol smember) -{ - if (smember) - { - AggregateDeclaration cd = null; - Dsymbol smemberparent = smember.toParent(); - if (smemberparent) - cd = smemberparent.isAggregateDeclaration(); - static if (LOG) - { - printf("AggregateDeclaration::hasPrivateAccess(class %s, member %s)\n", ad.toChars(), smember.toChars()); - } - if (ad == cd) // smember is a member of this class - { - static if (LOG) - { - printf("\tyes 1\n"); - } - return true; // so we get private access - } - // If both are members of the same module, grant access - while (1) - { - Dsymbol sp = smember.toParent(); - if (sp.isFuncDeclaration() && smember.isFuncDeclaration()) - smember = sp; - else - break; - } - if (!cd && ad.toParent() == smember.toParent()) - { - static if (LOG) - { - printf("\tyes 2\n"); - } - return true; - } - if (!cd && ad.getAccessModule() == smember.getAccessModule()) - { - static if (LOG) - { - printf("\tyes 3\n"); - } - return true; - } - } - static if (LOG) - { - printf("\tno\n"); - } - return false; -} - /**************************************** * Check access to d for expression e.d * Returns true if the declaration is not accessible. From f5cfb68a86e5c85f15612a24b5658c4960645d66 Mon Sep 17 00:00:00 2001 From: JinShil Date: Wed, 24 Apr 2019 15:18:57 +0900 Subject: [PATCH 25/25] Revert "Remove no longer needed code from access.d" This reverts commit c9585e0f339d815bfd78cca453956d950454b598. --- src/dmd/access.d | 232 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 230 insertions(+), 2 deletions(-) diff --git a/src/dmd/access.d b/src/dmd/access.d index 8f9b8521eefc..83275eed2da0 100644 --- a/src/dmd/access.d +++ b/src/dmd/access.d @@ -28,6 +28,103 @@ import dmd.tokens; private enum LOG = false; +/**************************************** + * Return Prot access for Dsymbol smember in this declaration. + */ +private Prot getAccess(AggregateDeclaration ad, Dsymbol smember) +{ + Prot access_ret = Prot(Prot.Kind.none); + static if (LOG) + { + printf("+AggregateDeclaration::getAccess(this = '%s', smember = '%s')\n", ad.toChars(), smember.toChars()); + } + assert(ad.isStructDeclaration() || ad.isClassDeclaration()); + if (smember.toParent() == ad) + { + access_ret = smember.prot(); + } + else if (smember.isDeclaration().isStatic()) + { + access_ret = smember.prot(); + } + if (ClassDeclaration cd = ad.isClassDeclaration()) + { + foreach (b; *cd.baseclasses) + { + Prot access = getAccess(b.sym, smember); + final switch (access.kind) + { + case Prot.Kind.none: + case Prot.Kind.undefined: + break; + case Prot.Kind.private_: + access_ret = Prot(Prot.Kind.none); // private members of base class not accessible + break; + case Prot.Kind.package_: + case Prot.Kind.protected_: + case Prot.Kind.public_: + case Prot.Kind.export_: + // If access is to be tightened + if (Prot.Kind.public_ < access.kind) + access = Prot(Prot.Kind.public_); + // Pick path with loosest access + if (access_ret.isMoreRestrictiveThan(access)) + access_ret = access; + break; + } + } + } + static if (LOG) + { + printf("-AggregateDeclaration::getAccess(this = '%s', smember = '%s') = %d\n", ad.toChars(), smember.toChars(), access_ret); + } + return access_ret; +} + +/******************************************************** + * Helper function for checkAccess() + * Returns: + * false is not accessible + * true is accessible + */ +private bool isAccessible(Dsymbol smember, Dsymbol sfunc, AggregateDeclaration dthis, AggregateDeclaration cdscope) +{ + assert(dthis); + version (none) + { + printf("isAccessible for %s.%s in function %s() in scope %s\n", dthis.toChars(), smember.toChars(), sfunc ? sfunc.toChars() : "NULL", cdscope ? cdscope.toChars() : "NULL"); + } + if (hasPrivateAccess(dthis, sfunc) || isFriendOf(dthis, cdscope)) + { + if (smember.toParent() == dthis) + return true; + if (ClassDeclaration cdthis = dthis.isClassDeclaration()) + { + foreach (b; *cdthis.baseclasses) + { + const Prot access = getAccess(b.sym, smember); + if (access.kind >= Prot.Kind.protected_ || isAccessible(smember, sfunc, b.sym, cdscope)) + { + return true; + } + } + } + } + else + { + if (smember.toParent() != dthis) + { + if (ClassDeclaration cdthis = dthis.isClassDeclaration()) + { + foreach (b; *cdthis.baseclasses) + if (isAccessible(smember, sfunc, b.sym, cdscope)) + return true; + } + } + } + return false; +} + /******************************* * Do access check for member of this class, this class being the * type of the 'this' pointer used to access smember. @@ -35,12 +132,59 @@ private enum LOG = false; */ bool checkAccess(AggregateDeclaration ad, Loc loc, Scope* sc, Dsymbol smember) { + FuncDeclaration f = sc.func; + AggregateDeclaration cdscope = sc.getStructClassScope(); static if (LOG) { printf("AggregateDeclaration::checkAccess() for %s.%s in function %s() in scope %s\n", ad.toChars(), smember.toChars(), f ? f.toChars() : null, cdscope ? cdscope.toChars() : null); } - - if (!symbolIsVisible(sc, smember) && (!(sc.flags & SCOPE.onlysafeaccess) || sc.func.setUnsafe())) + Dsymbol smemberparent = smember.toParent(); + if (!smemberparent || !smemberparent.isAggregateDeclaration()) + { + static if (LOG) + { + printf("not an aggregate member\n"); + } + return false; // then it is accessible + } + // BUG: should enable this check + //assert(smember.parent.isBaseOf(this, NULL)); + bool result; + Prot access; + if (smemberparent == ad) + { + access = smember.prot(); + result = access.kind >= Prot.Kind.public_ || hasPrivateAccess(ad, f) || isFriendOf(ad, cdscope) || (access.kind == Prot.Kind.package_ && hasPackageAccess(sc, smember)) || ad.getAccessModule() == sc._module; + static if (LOG) + { + printf("result1 = %d\n", result); + } + } + else if ((access = getAccess(ad, smember)).kind >= Prot.Kind.public_) + { + result = true; + static if (LOG) + { + printf("result2 = %d\n", result); + } + } + else if (access.kind == Prot.Kind.package_ && hasPackageAccess(sc, ad)) + { + result = true; + static if (LOG) + { + printf("result3 = %d\n", result); + } + } + else + { + result = isAccessible(smember, f, ad, cdscope); + static if (LOG) + { + printf("result4 = %d\n", result); + } + } + if (!result && (!(sc.flags & SCOPE.onlysafeaccess) || sc.func.setUnsafe())) { ad.error(loc, "member `%s` is not accessible%s", smember.toChars(), (sc.flags & SCOPE.onlysafeaccess) ? " from `@safe` code".ptr : "".ptr); //printf("smember = %s %s, prot = %d, semanticRun = %d\n", @@ -50,6 +194,34 @@ bool checkAccess(AggregateDeclaration ad, Loc loc, Scope* sc, Dsymbol smember) return false; } +/**************************************** + * Determine if this is the same or friend of cd. + */ +private bool isFriendOf(AggregateDeclaration ad, AggregateDeclaration cd) +{ + static if (LOG) + { + printf("AggregateDeclaration::isFriendOf(this = '%s', cd = '%s')\n", ad.toChars(), cd ? cd.toChars() : "null"); + } + if (ad == cd) + return true; + // Friends if both are in the same module + //if (toParent() == cd.toParent()) + if (cd && ad.getAccessModule() == cd.getAccessModule()) + { + static if (LOG) + { + printf("\tin same module\n"); + } + return true; + } + static if (LOG) + { + printf("\tnot friend\n"); + } + return false; +} + /**************************************** * Determine if scope sc has package level access to s. */ @@ -151,6 +323,62 @@ private bool hasProtectedAccess(Scope *sc, Dsymbol s) return sc._module == s.getAccessModule(); } +/********************************** + * Determine if smember has access to private members of this declaration. + */ +private bool hasPrivateAccess(AggregateDeclaration ad, Dsymbol smember) +{ + if (smember) + { + AggregateDeclaration cd = null; + Dsymbol smemberparent = smember.toParent(); + if (smemberparent) + cd = smemberparent.isAggregateDeclaration(); + static if (LOG) + { + printf("AggregateDeclaration::hasPrivateAccess(class %s, member %s)\n", ad.toChars(), smember.toChars()); + } + if (ad == cd) // smember is a member of this class + { + static if (LOG) + { + printf("\tyes 1\n"); + } + return true; // so we get private access + } + // If both are members of the same module, grant access + while (1) + { + Dsymbol sp = smember.toParent(); + if (sp.isFuncDeclaration() && smember.isFuncDeclaration()) + smember = sp; + else + break; + } + if (!cd && ad.toParent() == smember.toParent()) + { + static if (LOG) + { + printf("\tyes 2\n"); + } + return true; + } + if (!cd && ad.getAccessModule() == smember.getAccessModule()) + { + static if (LOG) + { + printf("\tyes 3\n"); + } + return true; + } + } + static if (LOG) + { + printf("\tno\n"); + } + return false; +} + /**************************************** * Check access to d for expression e.d * Returns true if the declaration is not accessible.