433 – A deprecated, same-named alias screws up resolution of imports

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 433 - A deprecated, same-named alias screws up resolution of imports
Summary: A deprecated, same-named alias screws up resolution of imports
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: Walter Bright
URL:
Keywords: rejects-valid, spec
Depends on:
Blocks: 340
Show dependency tree / graph
Reported: 2006年10月14日 15:18 UTC by Stewart Gordon
Modified: 2014年02月15日 13:22 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Stewart Gordon 2006年10月14日 15:18:19 UTC
If one module imports another module and declares an alias of a symbol in it with the same name, and then another module imports both and tries to use the symbol, then under current DMD the code generally compiles without any import conflict error.
The spec states that "Aliasing can be used to 'import' a symbol from an import into the current scope", but ought to make clearer the fact that doing so doesn't create import conflicts when both importer and importee are imported by a third module. Assuming that this is intended behaviour, which would make most sense.
However, if the alias is deprecated, it stops working. This situation is likely to occur when something is moved from one module to another, but kept as a deprecated alias in its old module.
----- dep_alias_1.d -----
private import dep_alias_2;
deprecated alias dep_alias_2.qwert qwert;
----- dep_alias_2.d -----
const int qwert = 42;
----- dep_alias_3.d -----
import dep_alias_1;
import dep_alias_2;
import std.stdio;
void main() {
	writefln(qwert);
}
----------
D:\My Documents\Programming\D\Tests\dep_alias_3.d(6): alias dep_alias_1.qwert is deprecated
----------
Even though dep_alias_3 imports both dep_alias_1 and dep_alias_2, it ignores dep_alias_2.qwert, which isn't deprecated at all.
If the imports in dep_alias_3.d are swapped, then the code compiles and runs without error.
Comment 1 Walter Bright 2006年11月25日 03:53:16 UTC
Fixed DMD 0.175


AltStyle によって変換されたページ (->オリジナル) /