Untyped string variable fails silently. No compiler warning given.

Adam D. Ruppe destructionator at gmail.com
Thu Mar 13 07:07:21 PDT 2014


On Thursday, 13 March 2014 at 13:57:49 UTC, Gary Willoughby wrote:
> 		text = Random(unpredictableSeed).front.to!(string);

This is actually calling the function std.conv.text.... this line 
is rewritten to:

std.conv.text(Random(unpredictableSeed).front.to!(string));

The text function converts all is arguments to string and returns 
them all concated together.

It thinks you are trying to use a property setter.

> 		// text is null here.
> 		return hexDigest!(CRC32)(text).array.to!(string);

And here, it is calling the text function with no arguments and 
no parens (similarly to a property getter). With no arguments, it 
just returns null.




So this isn't actually a bug, D is working as designed, but it is 
a better example than the common "writeln = 1;" thing given in 
most property setter arguments...


More information about the Digitalmars-d mailing list