Bug 12242 – conflict error with public imports

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-24T16:59:00Z
Last change time
2014-08-22T08:05:08Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
timothee.cour2

Comments

Comment #0 by timothee.cour2 — 2014-02-24T16:59:52Z
test.d: module test; public: import std.string; import std.algorithm; main.d: import test; import std.string; void main(){ auto a=" af ".strip;} dmd -c -o- main.d main.d(4): Error: test.strip at test.d conflicts with std.string.strip(C)(C[] str) if (isSomeChar!C) at phobos/std/string.d(1268) Remove any of the 4 imports and it'll compile. Also, there's no line number in 'at test.d'
Comment #1 by timothee.cour2 — 2014-02-24T17:01:08Z
actually this is a regression (worked in 2.063)
Comment #2 by dlang-bugzilla — 2014-02-24T20:53:55Z
Introduced in https://github.com/D-Programming-Language/phobos/pull/1311, but this really looks like a compiler bug in the vein of 314.
Comment #3 by k.hara.pg — 2014-03-18T18:18:29Z
Comment #4 by bugzilla — 2014-03-23T01:28:26Z
This is not a compiler bug. It has nothing to do with 314. The problem is that 'strip' is defined in both std.string and std.algorithm.
Comment #5 by dlang-bugzilla — 2014-03-23T01:33:53Z
This is a compiler bug because this program doesn't compile (as is expected): /////// test.d ////// import std.algorithm; void main() { " af ".strip; } ///////////////////// And this program compiles (as it should): /////// test.d ////// import std.algorithm; import std.string; void main() { " af ".strip; } ///////////////////// Note that the above program differs from OP's only in how imports are "funneled". Therefore, there should be no conflict, because out of std.algorithm.strip and std.string.strip, only one will work with those parameters.
Comment #6 by k.hara.pg — 2014-03-23T08:57:48Z
(In reply to comment #4) > This is not a compiler bug. It has nothing to do with 314. > The problem is that 'strip' is defined in both std.string and std.algorithm. This is a compiler bug on cross-module overload set handling. It's not directly related to issue 313 & 314. > test.d: > module test; > public: > import std.string; > import std.algorithm; In test.d, 'strip' is a cross module overload set (CMOS) of 'std.string.strip' and 'std.algorithm.strip'. > main.d: > import test; > import std.string; > void main(){ auto a=" af ".strip;} In main.d, 'strip' is a CMOS of the CMOS in test.d and 'std.stding.strip'. So, the newly created CMOS should be merged to the set [std.string.strip, std.algorithm.strip]. But currently OverloadSet and template cannot be merged into one OverloadSet object in ScopeDsymbol::search.
Comment #7 by k.hara.pg — 2014-05-14T13:40:03Z
One more test case of this issue: module test01; private mixin template MixTmp(T, int x) { template foo(U) if (is(U == T)) { enum foo = x; } } mixin MixTmp!(int, 1); mixin MixTmp!(long, 2); ------------ module test02; private mixin template MixTmp(T, int x) { template foo(U) if (is(U == T)) { enum foo = x; } } mixin MixTmp!(float, 3); mixin MixTmp!(real, 4); ------------ import test01, test02; import std.stdio; void main() { writeln( foo!int ); } In module test01 and test02, 'foo' make individual overload sets. And in module test03, the imported two overload sets 'foo' should be merged to a new overload set 'foo' which contains four mixed-in templates.
Comment #8 by k.hara.pg — 2014-07-29T14:30:24Z
(In reply to Walter Bright from comment #4) > This is not a compiler bug. It has nothing to do with 314. > > The problem is that 'strip' is defined in both std.string and std.algorithm. But their signatures don't have ambiguity. With one string argument, " af ".strip == strip(" af ") should match only to std.string.strip. So this is a compiler bug.
Comment #9 by github-bugzilla — 2014-07-29T23:10:03Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f1130bf5762a21697708a3fe94eb291cdf4c3074 fix Issue 12242 - conflict error with public imports https://github.com/D-Programming-Language/dmd/commit/79a406dfdbeda7d1f5b21e52252c07cb6a6cc839 Merge pull request #3388 from 9rnsr/fix12242 Issue 12242 - conflict error with public imports
Comment #10 by code — 2014-07-29T23:19:22Z
Is this a duplicate of issue 7327?
Comment #11 by hsteoh — 2014-07-29T23:26:43Z
Issue #7327 appears to have been fixed by https://github.com/D-Programming-Language/dmd/pull/3388. Tested on Linux/64bit, on git HEAD.
Comment #12 by code — 2014-07-29T23:29:50Z
I don't like the term cross module overload set, because an overload sets is a set of overloads from different modules (or mixin templates) by definition. The bug resolution to flatten all nested overload sets into a single overload set seems to be semantically correct.
Comment #13 by code — 2014-07-29T23:30:24Z
*** Issue 7327 has been marked as a duplicate of this issue. ***
Comment #14 by github-bugzilla — 2014-07-31T02:35:22Z
Commit pushed to 2.066 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/01bab81bb9d078886fded28d30b11af8cc866a54 Merge pull request #3388 from 9rnsr/fix12242 Issue 12242 - conflict error with public imports
Comment #15 by github-bugzilla — 2014-08-22T08:05:08Z