[Issue 9047] Expression requiring std.math fails with function-local import

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 23 07:54:21 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9047



--- Comment #7 from bearophile_hugs at eml.cc 2013-03-23 07:54:19 PDT ---
void main() {
    import std.stdio;
    int x = 3;
    immutable j = 2 ^^ x;
}


Error received:

temp.d(4): Error: undefined identifier 'std'


Expected error:

temp.d(4): Error: must import std.math to use ^^ operator



That problem causes curious cascades of errors like:


void main() {
    import std.stdio;
    enum size_t N = 5;
    char[N][N] mat = '0';
    int e = 0;
    foreach (immutable i, ref row; mat) {
        immutable j = (i + (2 ^^ e)) % N;
        row[j] = '1';
    }
    writeln(mat);
}



temp.d(7): Error: undefined identifier 'std'
...\dmd2\src\phobos\std\range.d(611): Error: static assert  "Cannot put a
const(dchar) into a Appender!(char[])"
...\dmd2\src\phobos\std\format.d(2163):        instantiated from here:
put!(Appender!(char[]), const(dchar))
...\dmd2\src\phobos\std\format.d(2210):        instantiated from here:
formatChar!(Appender!(char[]))
...\dmd2\src\phobos\std\format.d(2113):        instantiated from here:
formatElement!(LockingTextWriter, char[5u], char)
...\dmd2\src\phobos\std\format.d(1827):        ... (5 instantiations, -v to
show) ...
...\dmd2\src\phobos\std\stdio.d(1622):        instantiated from here:
write!(char[5u][5u],char)
temp.d(10):        instantiated from here: writeln!(char[5u][5u])

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list