Strange cast error in compile-time function
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Tue Jul 24 12:11:23 PDT 2007
Stéphan Kochen wrote:
> Now it's complaining about genSingleCategoryIf. I can't seem to identify
> this with any of the earlier problems.
[snip]
> private string uintToString(uint i)
> {
> if (i < 10)
> return [cast(char) (i + '0')];
> else
> return uintToString(i / 10) ~ uintToString(i % 10);
> }
>
> private string genSingleCategoryIf(string prop, uint start, uint end)
> {
> if (start == end)
> {
> return "if (c == " ~ uintToString(start) ~ ")\n" ~
> " return GeneralCategory." ~ prop ~ ";\n" ~
> "else ";
> }
> else
> {
> return "if (c >= " ~ uintToString(start) ~ " && " ~
> "c <= " ~ uintToString(end) ~ ")\n" ~
> " return GeneralCategory." ~ prop ~ ";\n" ~
> "else ";
> }
> }
DMD doesn't seem to like that call to uintToString(start) from
genSingleCategoryIf, even though it works fine on its own. The
workaround is simple though, just change the single-digit case to
'return "0123456789"[i..i+1];'.
More information about the Digitalmars-d
mailing list