www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23468] New: [betterC] Cannot use std.array.join and

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

          Issue ID: 23468
           Summary: [betterC] Cannot use std.array.join and
                    std.algorithm.map at compile-time
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: moconnor tutanota.com

It looks like certain aspects of CTFE are disabled when building with -betterC.
I assume this is a bug?

```
struct Vector2 {
    int x, y;
}

extern(C) void main() {
    import std.algorithm : map;
    import std.range : join;
    import std.traits : FieldNameTuple;
    enum fragment = [FieldNameTuple!Vector2].map!(field => "0.").join(",");
    Vector2 zero = mixin("Vector2(" ~ fragment ~ ")");
}
```

When compiled with `dmd -betterC betterc.exe .\betterc.d`, I get:

```
.\betterc.d(9): Error: none of the overloads of template `std.array.join` are
callable using argument types `!()(MapResult!(__lambda1, string[]), string)`
dmd\current\windows\bin64\..\..\src\phobos\std\array.d(2125):        Candidates
are: `join(RoR, R)(RoR ror, R sep)`
  with `RoR = MapResult!(__lambda1, string[]),
       R = string`
  must satisfy the following constraint:
`       isInputRange!(Unqual!(ElementType!RoR))`
dmd\current\windows\bin64\..\..\src\phobos\std\array.d(2228):                  
     `join(RoR, E)(RoR ror, scope E sep)`
  with `RoR = MapResult!(__lambda1, string[]),
       E = string`
  must satisfy the following constraint:
`       isInputRange!(Unqual!(ElementType!RoR))`
dmd\current\windows\bin64\..\..\src\phobos\std\array.d(2321):                  
     `join(RoR)(RoR ror)`
```

--
Nov 06 2022