www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15114] New: hijacking and selective imports

https://issues.dlang.org/show_bug.cgi?id=15114

          Issue ID: 15114
           Summary: hijacking and selective imports
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: john.loughran.colvin gmail.com

v1:
===
import std.math;

auto sin(float x) { return .sin(x); }

void main() { auto a = sin(3.4f); }

hijack.d(3): Error: forward reference to inferred return type of function call
module hijack.sin(x)

v2:
===
import std.math;

auto sin(float x) { return std.math.sin(x); }

void main() { auto a = sin(3.4f); }

No errors

v3:
===
import std.math : sin;

auto sin(float x) { return std.math.sin(x); }

void main() { auto a = sin(3.4f); }

hijack.d(3): Error: undefined identifier 'std'

v4:
===
import std.math : sin;

auto sin(float x) { return .sin(x); }

void main() { auto a = sin(3.4f); }

hijack.d(3): Error: hijack.sin called with argument types (float) matches both:
/usr/local/Cellar/dmd/2.068.2/include/d2/std/math.d(664):    
std.math.sin(float x)
and:
hijack.d(3):     hijack.sin(float x)

v5:
===
import std.math;
import std.math : sin;

auto sin(float x) { return std.math.sin(x); }

void main() { auto a = sin(3.4f); }

hijack.d(6): Error: hijack.sin called with argument types (float) matches both:
/usr/local/Cellar/dmd/2.068.2/include/d2/std/math.d(664):    
std.math.sin(float x)
and:
hijack.d(4):     hijack.sin(float x)


Comparing v2 and v3:
Why does using a selective import prevent use of the fully qualified name?

Comparing v1 and v4:
Why does using a selective import completely change the error message?

comparing v2 and v5:
Why does adding a selective import trigger a conflict? Why is there not a
conflict in v2?


It seems like either I am totally misunderstanding things or some of these are
bugs.

--
Sep 25 2015