[Issue 16584] New: Local import ineffective for mixin templates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Oct 3 15:03:25 PDT 2016


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

          Issue ID: 16584
           Summary: Local import ineffective for mixin templates
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: m.bierlee at lostmoment.com

Consider the following code:
// func.d
module func;

public uint toNumber(string str) {
    return str[0];
}

// mixins.d
module mixins;

import func;

mixin template bla(string number) {
    uint globalBla = toNumber(number);
}

// app.d
module app;

import mixins;

public void main() {
    mixin bla!"aaa";
}

When compiled, the following compilation error is shown:
src\mixins.d(6,19): Error: undefined identifier 'toNumber'
src\app.d(6,2): Error: mixin app.main.bla!"aaa" error instantiating

I expected the import of module 'func' to be only needed at the site of the
mixin declaration, not where the mixin is used.

Publicly importing module 'func' in mixins.d works around the problem, as does
importing module 'func' in app.d.

--


More information about the Digitalmars-d-bugs mailing list