Issue 23468 - [betterC] Cannot use std.array.join and std.algorithm.map at compile-time
Summary: [betterC] Cannot use std.array.join and std.algorithm.map at compile-time
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords: betterC
Depends on:
Blocks:
 
Reported: 2022-11-06 22:53 UTC by Matthew O
Modified: 2023-01-08 17:00 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Matthew O 2022-11-06 22:53:35 UTC
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)`
```