www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16584] New: Local import ineffective for mixin templates


          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 puremagic.com
          Reporter: m.bierlee 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.

Oct 03 2016