Reading a string from standard input and trying to compare it with an integer, like this:
-----
if ((sn = readln ()) > 0) {}
-----
triggers an error:
-----
Internal error: e2ir.c 1902
-----
A full example follows. It reproduces for me on DMD 2.065.0-2.066.0 on Win32. With 2.064.2 and earlier, I get a somewhat better "Array operation not implemented" compiler error. Decomposing the problematic line also gives a normal "Incompatible types" error.
-----
import std.stdio, std.string;
void main () {
string sn;
if ((sn = readln ()) > 0) {
}
}
-----
The story is that I was first reading an integer, like this:
-----
while (readf (" %s", &n) > 0) {...}
-----
and later changed reading an integer to reading a string, but forgot to fix the exit condition.
Anyway, an internal compiler error does not specify the line of my source file, which is inconvenient.
Comment #1 by gassa — 2014-08-27T13:38:55Z
Created attachment 1389
example code
Comment #2 by hsteoh — 2014-09-11T22:37:26Z
For small code examples, you can just post the entire code in a comment, like so:
-----
import std.stdio;
void main () {
string sn;
if ((sn = readln ) > 0) {
}
}
-----
There is no line number in the error message probably because by the time the compiler getse to e2ir.c, it's already emitting code, and by that point the semantic passes may have transformed the code significantly so that line number information may not be readily available.
In any case, the error is caused by the `if ((sn = readln) > 0)` line. Now, to hack the dmd makefiles so that I can get it to build with debugging symbols...