www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21347] New: std.functional.adjoin should work in BetterC

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

          Issue ID: 21347
           Summary: std.functional.adjoin should work in BetterC
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

Example program:

---
extern(C) int main()
{
    import std.functional: adjoin;

    alias f = (int n) => n + 1;
    alias g = (int n) => n + 2;
    alias h = (int n) => n + 3;
    alias i = (int n) => n + 4;

    auto result = adjoin!(f, g, h, i)(0);

    assert(result[0] == 1);
    assert(result[1] == 2);
    assert(result[2] == 3);
    assert(result[3] == 4);

    return 0;
}
---

Compiler output:

---
$ dmd -betterC bug.d
/usr/include/dmd/phobos/std/array.d(3243): Error: TypeInfo cannot be used with
-betterC
$ dmd --version
DMD64 D Compiler v2.094.0
---

Note that due to details of the current implementation, only calls to adjoin
with 4 or more template arguments are affected as of Phobos 2.094.0.

--
Oct 28 2020