Tango error : cannot modify immutable expression *p++
jeromeG
jero.gaultier at gmail.com
Thu Sep 10 20:55:17 UTC 2020
Hi people,
I am using the tango-1.0.5_2.0.85 package in my project, for some
reasons :)
This packages contains tango/tango/text/convert/Float.d
I was just compiling my program and got this error:
../../../.dub/packages/tango-1.0.5_2.0.85/tango/tango/text/convert/Float.d(251,13): Error: cannot modify immutable expression *p++
In fact, there are a dozen similar errors with Float.d, because
the code shows the following in different places:
-----
auto p = dst.ptr;
if (sign)
*p++ = '-'; <<< this is problematic
-----
dst is from the function argument list :
T[] format(T) (T[] dst, NumType x, int decimals=Dec, int e=Exp,
bool pad=Pad)
I don't understand why dst is immutable at the first place... I
guess the error pops up because the template argument passed as T
is immutable itself. But in this case, I don't see how we can
return a modified dst at any point.
I try a few Rebindable combos, but a bit randomly, as I don't
understand exactly what Rebindable is for. Not to avail.
Compiler output:
-------------------------
$ dub build
Performing "debug" build using
/home/jegau/dlang/dmd-2.093.1/linux/bin64/dmd for x86_64.
diamond ~master: building configuration "library"...
src/diamond/core/misc.d(177,27): Error: undefined identifier
doFormat in module std.format
src/diamond/gui/surfacegeometry.d(163,13): Warning: ubyte *=
float is performing truncating conversion
src/diamond/gui/surfacegeometry.d(174,7): Warning: ubyte *= float
is performing truncating conversion
../../../.dub/packages/tango-1.0.5_2.0.85/tango/tango/text/convert/Float.d(251,13): Error: cannot modify immutable expression *p++
../../../.dub/packages/tango-1.0.5_2.0.85/tango/tango/text/convert/Float.d(255,20): Error: cannot modify immutable expression *p++
../../../.dub/packages/tango-1.0.5_2.0.85/tango/tango/text/convert/Float.d(261,15): Error: cannot modify immutable expression *p++
../../../.dub/packages/tango-1.0.5_2.0.85/tango/tango/text/convert/Float.d(265,18): Error: cannot modify immutable expression *p++
../../../.dub/packages/tango-1.0.5_2.0.85/tango/tango/text/convert/Float.d(267,25): Error: cannot modify immutable expression *p++
.... (more similar errors)
Any shining light appreciated.
More information about the Digitalmars-d
mailing list