www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18774] New: meta used in .di files causes link errors


          Issue ID: 18774
           Summary: meta used in .di files causes link errors
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

We produce a function prototype in a .di file using some meta

module test;

template Test()
    import std.range, std.algorithm;
    enum Test = "void test_func(" ~
                                  zip(["int","int"], ["a","b"])
                                    .map!(tuple => tuple[0] ~ " " ~ tuple[1])
                                    .reduce!((a, b) => a ~ ", " ~ b) ~
mixin(Test!()); // <- Mixes in: void test_func(int a, int b);

import test;

int main()
    test_func(1, 2);

    return 0;

I expect compiling this example to result in a single link error to the
unresolved external test_func().
But we also see "error LNK2001: unresolved external symbol

Calling zip() at CTFE results in an additional unexpected link error.
Using a function in CTFE this way shouldn't affect the symbol table, or add any
additional link references.

Apr 17 2018