[Bug 123] Use of function, modulus, and dollar sign (length) fails to compile with static and const

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 1 19:25:08 PDT 2006


http://d.puremagic.com/bugzilla/show_bug.cgi?id=123





------- Comment #1 from ddparnell at bigpond.com  2006-05-01 21:25 -------
This works...
// --------------
import std.stdio;
uint intRes()
{
        return 4;
}
const char [6]foo = "abc123";
void main()
{
    writefln( foo[intRes() % length] );
}
// --------------


This fails...
// --------------
import std.stdio;
uint intRes()
{
        return 4;
}
const char []foo = "abc123";
void main()
{
    writefln( foo[intRes() % length] );
}
// --------------

This works...
// --------------
import std.stdio;
uint intRes()
{
        return 4;
}
const char []foo = "abc123";
void main()
{
    writefln( foo[intRes() % foo.length] );
}
// --------------

This works...
// --------------
import std.stdio;
uint intRes()
{
        return 4;
}
char []foo = "abc123";
void main()
{
    writefln( foo[intRes() % length] );
}
// --------------

This works...
// --------------
import std.stdio;
uint intRes()
{
        return 4;
}
const char []foo = "abc123";
void main()
{
    writefln( foo[4 % length] );
}
// --------------


-- 




More information about the Digitalmars-d-bugs mailing list