[Issue 22325] New: ReplaceType fails on templated type instantiated with void-returning function
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 20 15:32:46 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22325
Issue ID: 22325
Summary: ReplaceType fails on templated type instantiated with
void-returning function
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: snarwin+bugzilla at gmail.com
As of DMD 2.097.2, the following program fails to compile:
---
import std.typecons;
struct Foo(alias f) {}
void bar() {}
alias _ = ReplaceType!(int, int, Foo!bar);
---
The error message is:
---
/usr/include/dmd/phobos/std/typecons.d(9067): Error: variable
`std.typecons.ReplaceTypeUnless!(false_, int, int,
Foo!(bar)).F!(bar).replaceTemplateArgs` type `void` is inferred from
initializer `bar()`, and variables cannot be of type `void`
/usr/include/dmd/phobos/std/meta.d-mixin-794(794): Error: template instance
`std.typecons.ReplaceTypeUnless!(false_, int, int, Foo!(bar)).F!(bar)` error
instantiating
/usr/include/dmd/phobos/std/typecons.d(9071): instantiated from here:
`staticMap!(replaceTemplateArgs, bar)`
/usr/include/dmd/phobos/std/typecons.d(9012): instantiated from here:
`ReplaceTypeUnless!(false_, int, int, Foo!(bar))`
bug.d(5): instantiated from here: `ReplaceType!(int, int, Foo!(bar))`
---
--
More information about the Digitalmars-d-bugs
mailing list