Bug 313 – [module] Fully qualified names bypass private imports

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2006-08-27T09:35:22Z
Last change time
2020-05-19T01:26:52Z
Keywords
accepts-invalid, bounty, pull
Assigned to
Walter Bright
Creator
Matti Niemenmaa
Blocks
314, 2830, 3108

Comments

Comment #0 by matti.niemenmaa+dbugzilla — 2006-08-27T09:35:22Z
In file a.d: -- // explicit private no longer needed but added for clarity private import std.stdio; -- In file b.d: -- import a; void main() { // compiler correctly reports "undefined identifier writefln" writefln("foo"); // works fine! std.stdio.writefln("foo"); }
Comment #1 by thomas-dloop — 2006-09-13T17:40:34Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-08-27: > http://d.puremagic.com/issues/show_bug.cgi?id=313 > In file a.d: > -- > // explicit private no longer needed but added for clarity > private import std.stdio; > -- > In file b.d: > -- > import a; > > void main() { > // compiler correctly reports "undefined identifier writefln" > writefln("foo"); > // works fine! > std.stdio.writefln("foo"); > } Added to DStress as ( http://dstress.kuehne.cn/addon/import_16_A.d ) ( http://dstress.kuehne.cn/addon/import_16_B.d ) http://dstress.kuehne.cn/nocompile/i/import_16_C.d http://dstress.kuehne.cn/nocompile/i/import_16_D.d http://dstress.kuehne.cn/nocompile/i/import_16_E.d http://dstress.kuehne.cn/nocompile/i/import_16_F.d http://dstress.kuehne.cn/nocompile/i/import_16_G.d http://dstress.kuehne.cn/nocompile/i/import_16_H.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFFCI/kLK5blCcjpWoRAr2vAJ9kMpOBRbvfc+shCaY5sUmJ2A0mHgCgiqwL gXiXz3j5CfhZNxSD/od/FP4= =t6HB -----END PGP SIGNATURE-----
Comment #2 by davidl — 2007-01-23T04:25:51Z
d 1.0 does correctly report the error message
Comment #3 by thomas-dloop — 2007-01-23T07:44:42Z
David, did you test on Windows? import_16_C, D, F - H still fail on Linux.
Comment #4 by thomas-dloop — 2007-01-24T02:09:19Z
*** Bug 880 has been marked as a duplicate of this bug. ***
Comment #5 by bugzilla — 2008-12-08T00:52:07Z
Although this particular bug is fixed as of dmd 1.037 and 2.021, there are other cases that fail.
Comment #6 by code — 2012-01-24T04:16:25Z
---- a.d ---- import b; void main() { std.stdio.writefln("Hello"); } ---- b.d ---- public import std.ascii; private import std.stdio; ------------- dmd -c a
Comment #7 by code — 2012-02-16T18:46:11Z
*** Issue 1504 has been marked as a duplicate of this issue. ***
Comment #8 by code — 2012-02-16T19:09:37Z
*** Issue 5411 has been marked as a duplicate of this issue. ***
Comment #9 by code — 2012-02-16T19:28:48Z
*** Issue 6307 has been marked as a duplicate of this issue. ***
Comment #10 by code — 2012-02-16T19:34:55Z
*** Issue 7496 has been marked as a duplicate of this issue. ***
Comment #11 by code — 2012-02-16T19:39:43Z
The issue is that all imports are inserted into a global package tree. Whenever you have access to a root package, e.g. by importing std.stdio, one can access all 'std' children that were imported with a qualified name. A possible fix would be to create one package tree (or a view of it) for each module.
Comment #12 by github-bugzilla — 2013-06-24T09:43:47Z
Commit pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/efe7e94030d75780b16a4eaf45c8dfb789c899aa Merge pull request #532 from 9rnsr/fix_imports Issue 313 & 314 - Add package access to rt.lifetime.BlkInfo
Comment #13 by github-bugzilla — 2013-06-24T18:48:40Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/03a32d6fa4635543eed17b874fbf7a0330572ac3 Fix issue 313 & 314 https://github.com/D-Programming-Language/phobos/commit/b7216eae2e9ec73e186a713c59839fd91c9347b7 Merge pull request #1368 from 9rnsr/fix_imports Fix issue 313 & 314 - Add necessary imports and fix FQN accesses
Comment #14 by k.hara.pg — 2013-06-24T23:04:14Z
Comment #15 by github-bugzilla — 2013-06-25T01:52:36Z
Comment #16 by github-bugzilla — 2013-12-24T00:31:26Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/3e791f6bc6046e4ca7e9e650a573ffaa9f0c3403 Add import declarations for issue 313 & 314 https://github.com/D-Programming-Language/phobos/commit/e2e986c7b6533c9042dbbdc23960e287e206ea12 Merge pull request #1811 from 9rnsr/fix_imports Add import declarations for issue 313 & 314
Comment #17 by github-bugzilla — 2014-03-15T16:49:32Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9c204d91275664a4c91c42b61bdad0c05849a6c7 fix Issue 313 - [module] Fully qualified names bypass private imports https://github.com/D-Programming-Language/dmd/commit/6cf399220142a05aba69be2f1ed489496a625aff Merge pull request #2256 from 9rnsr/fix_imports Fix issue 313 & 314 implement more strict import mechanism
Comment #18 by k.hara.pg — 2014-05-28T04:04:26Z
(In reply to Kenji Hara from comment #14) > https://github.com/D-Programming-Language/dmd/pull/2256 Unfortunately it was finally reverted. Instead of that, more conservative fix for the issues 313 & 311 is now opened. https://github.com/D-Programming-Language/dmd/pull/3407
Comment #19 by code — 2016-02-13T20:01:30Z
Comment #20 by github-bugzilla — 2016-02-20T16:06:49Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ea25aad26d11951ccbcd2a57f8c3add968f32434 fix Issue 313 - Fully qualified names bypass private imports - b/c we're using a global package tree, imported modules were accessible in other scopes using fully qualified names - maintain a whitelist of imported modules in the current scope https://github.com/D-Programming-Language/dmd/commit/eb8c2c7a48404495d3a62ee5bd58e28a654e99d5 Merge pull request #5426 from MartinNowak/fix313 fix Issue 313 - Fully qualified names bypass private imports
Comment #21 by maximzms — 2016-03-31T06:24:08Z
*** Issue 13709 has been marked as a duplicate of this issue. ***
Comment #22 by github-bugzilla — 2018-10-25T09:30:56Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/aca10e8a720d8a00a09184e5fc065665ca3a2c13 Turn deprecation into error for issue 313 https://github.com/dlang/dmd/commit/01a6a5e26f7d2ed6fdab9286566ece803862c48a Merge pull request #8443 from RazvanN7/checkAccess_err Turn deprecation into error for issue 313 merged-on-behalf-of: Sebastian Wilzbach <[email protected]>
Comment #23 by dkorpel — 2019-05-05T15:11:42Z
*** Issue 13462 has been marked as a duplicate of this issue. ***