[Issue 15179] Local imports cause outer imports to be excluded from overload set

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Mar 24 07:30:16 PDT 2016


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

--- Comment #5 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Jesse Phillips from comment #4)
> Main calls bar.foobar and the assertion passes.
> 
> ----------
> import bar;
> 
> void main() {
> import foo;
>     assert(7.foobar);
> }

I'm surprised this works, because I would expect foo to not overload with bar's
functions, it has priority. I'm not sure how the current lookup rules work or
the rules for the new system about to be released (with all the import rule
fixes).

But in the final version, I would expect foo's foobar overload set to be
prioritized, because it was imported locally and has priority.

But we can "fix" the demonstration by removing the foobar(string) from foo, so
it wouldn't have been used as an overload set in the first place (similar to
the original code example).

In any case, the solution here is to do a selective import in a scope, which
works as expected. Alternatively, you can import both modules at the same scope
so they are used at the same priority.

--


More information about the Digitalmars-d-bugs mailing list