D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12994 - Function-local imported name shadowing error
Summary: Function-local imported name shadowing error
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P1 enhancement
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2014-06-26 08:47 UTC by bearophile_hugs
Modified: 2022-09-05 17:42 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2014-06-26 08:47:14 UTC
This is an enhancement request, but it's borderline being a bug report for the module system.

Two similar examples:


void main() {
    int map;
    import std.algorithm;
    map!(x => x)([1]);
}



void main() {
    int map;
    import std.algorithm: map;
    map!(x => x)([1]);
}


In both cases dmd 2.066alpha gives:

test.d(4,8): Error: no property 'map' for type 'int[]'
test.d(5,5): Error: template instance map!((x) => x) map is not a template declaration, it is a variable


In both programs I expect something like a "'map' identifier shadowing error".

An explicit "import std.algorithm: map;" getting totally ignored is not acceptable, in my opinion.
Comment 1 Wyatt 2016-02-26 17:09:40 UTC
Since 2.071 seems to be The Module System release (finally fixing Issue 313, Issue 314 (hopefully), and Issue 10378), maybe this should be addressed as well?
Comment 2 Nick Treleaven 2022-09-05 17:42:10 UTC
Either now gives:

mapconflict.d(4): Error: template instance `map!((x) => x)` `map` is not a template declaration, it is a variable