[Issue 12359] New: implicit overload merging with selective/renamed imports should be removed

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 13 17:22:17 PDT 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12359

           Summary: implicit overload merging with selective/renamed
                    imports should be removed
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: k.hara.pg at gmail.com


--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2014-03-13 17:22:11 PDT ---
Currently, selective or renamed imports create alias declaration implicitly.

  import a : b;
  // is mostly equivalent with:
  // import a; alias b = a.b;

  import a : x = b;
  // is mostly equivalent with:
  // import a; alias x = a.b;

But it is problematic behavior, because it would implicitly merge overloads in
the imported module. For example:

  import std.ascii : isDigit;   // bool isDigit(dchar c)

  bool isDigit(char c) { return true; }
  // Here isDigit is an overload set of bool(char) and bool(dchar)

  void main() {
    dchar d = 'a';
    isDigit(d);   // matches to std.ascii.isDiigt
  }

I think import declarations should only handle symbol visibility. So the
current behavior is not orthogonal. Therefore it should be deprecated and
finally removed.

To reproduce same behavior, explicit alias should work.

  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
  }

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list