Bug 12398 – Selective imports no longer act as static imports

Status
RESOLVED
Resolution
INVALID
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-18T04:15:00Z
Last change time
2014-03-24T00:17:42Z
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2014-03-18T04:15:43Z
////////// test.d ///////// import std.stream : Stream; void main() { std.stream.File f; } /////////////////////////// I don't see any purpose for this breakage.
Comment #1 by andrej.mitrovich — 2014-03-18T04:22:45Z
(In reply to comment #0) > ////////// test.d ///////// > import std.stream : Stream; > > void main() > { > std.stream.File f; > } > /////////////////////////// > > I don't see any purpose for this breakage. According to this[1] comment the above should work. [1] https://d.puremagic.com/issues/show_bug.cgi?id=12359#c0 Comment: ----- import std.ascii : isDigit; // Don't create alias silently bool isDigit(char c) { return true; } alias isDigit = std.ascii.isDigit; // explicitly merge overloads void main() { dchar d = 'a'; isDigit(d); // matches to std.ascii.isDiigt } -----
Comment #2 by bearophile_hugs — 2014-03-18T05:16:58Z
(In reply to comment #0) > ////////// test.d ///////// > import std.stream : Stream; > > void main() > { > std.stream.File f; > } > /////////////////////////// > > I don't see any purpose for this breakage. Here you have asked to import just the name "Stream", so the "std.stream" name is missing. This is how things should be in a serious implementation of a module system.
Comment #3 by k.hara.pg — 2014-03-18T06:50:24Z
(In reply to comment #0) > ////////// test.d ///////// > import std.stream : Stream; > > void main() > { > std.stream.File f; > } > /////////////////////////// > > I don't see any purpose for this breakage. What's changed? With 2.065: test.d(5): Error: undefined identifier std.stream.File With git-head: test.d(5): Error: undefined identifier 'File' test.d(5): Error: std.stream.File is used as a type Excepting the minor diagnostic change, the failing compilation is the expected result.
Comment #4 by andrej.mitrovich — 2014-03-18T07:46:02Z
I think Vlad's test-case was probably from his AE lib. The issue is likely that 'std.stream' was publicly available from within some other module, for example this works in 2.065: ----- import std.stdio; // comment this out for failure import std.stream : Stream; void main() { new std.stream.File(__FILE__); } ----- This no longer works in git-head, but I think that's ok.
Comment #5 by k.hara.pg — 2014-03-18T07:55:58Z
(In reply to comment #4) > I think Vlad's test-case was probably from his AE lib. The issue is likely that > 'std.stream' was publicly available from within some other module, for example > this works in 2.065: > > ----- > import std.stdio; // comment this out for failure > import std.stream : Stream; > > void main() > { > new std.stream.File(__FILE__); > } > ----- > > This no longer works in git-head, but I think that's ok. Yes, it is exactly the issue 313, it should be rejected in git-head.
Comment #6 by dlang-bugzilla — 2014-03-18T16:07:43Z
Oh, I see. Thanks. Invalid? Or enhancement? I think selective imports ought to also act as static imports.
Comment #7 by andrej.mitrovich — 2014-03-19T01:11:01Z
(In reply to comment #6) > Oh, I see. Thanks. > > Invalid? Or enhancement? I think selective imports ought to also act as static > imports. For that I suggest: ----- static import std.stream : Stream; void main() { std.stream.File f; } ----- This is currently disallowed: Error: static import stream cannot have an import bind list So it wouldn't be a breaking change to add support.
Comment #8 by dlang-bugzilla — 2014-03-19T01:12:51Z
(In reply to comment #7) > static import std.stream : Stream; Honestly if I saw that, I'd think it only allowed referring only to Stream and only by its fully-qualified name.