[Issue 21539] [REG 2.084] symbols from import inside template mixin cannot be accessed using module scope dot operator

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 20 15:03:33 UTC 2021


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

--- Comment #4 from Steven Schveighoffer <schveiguy at gmail.com> ---
At first, I thought I had an easy counter-case, but this also doesn't work:

void main()
{
   import std.stdio;
   .writeln("hello"); // error, no symbol writeln
}

And this case is not a regression (at least back to 2.060).

I understand the point here, but I need something that mixes in the symbols AS
IF they were in the module. A mixin string works, but I need it to be a
template to avoid a complete mess in documentation and code maintenance.

As you probably are aware, the real case is not this simple. What I'm trying to
do is migrate a phobos module from a standard module to one that is
configurable based on a template parameter. I would like the entire module to
be copied as-is, just inside a mixin template (with certain pieces using the
template parameter instead). Any usage of the dot operator is going to be
troublesome (and of course, the reason it's used is not on a whim).

The problem is, I don't have a universal substitute for the dot operator in
this case. I need something that says "at mixin scope"

If I use:

mixin template T()
{
   import std.stdio;
   alias X = T.File;
}

It doesn't work.

I may have to remove all . scope operators in Phobos to get this to work (and
instead use FQN).

--


More information about the Digitalmars-d-bugs mailing list