[Issue 24880] New: to!string with inout enum argument fails to compile
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 25 15:46:38 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24880
Issue ID: 24880
Summary: to!string with inout enum argument fails to compile
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.109.1, the following program fails to compile:
---
enum E { One }
inout(E) fun(inout(E) e)
{
import std.conv;
auto s = e.to!string;
return e;
}
---
The error message is:
---
/usr/include/dmd/phobos/std/conv.d(1227): Error: variable `std.conv.value` -
only parameters or stack-based variables can be `inout`
/usr/include/dmd/phobos/std/conv.d(210): Error: template instance
`std.conv.toImpl!(string, inout(E))` error instantiating
bug.d(6): instantiated from here: `to!(inout(E))`
---
This error occurs because toImpl attempts to pass an inout(E) value as an
argument to the template enumRep. The instantiation fails because inout values
cannot be used as template arguments:
---
enum E { One }
enum example(T, T value) = true;
alias test = example!(inout(E), E.One);
// Error: only parameters or stack-based variables can be `inout
---
--
More information about the Digitalmars-d-bugs
mailing list