Compiler bug: Incorrect line in error message

Shachar Shemesh shachar at weka.io
Sun Jan 14 12:24:58 UTC 2018


Please consider the following program:

struct V {
     int a;
}

struct S {
     enum A = V(12); // Line 6
}

void main() {
     int b = cast(int)S.A; // Line 10
}

It fails to compile:
test2.d(6): Error: cannot cast expression V(12) of type V to int

Everything about this error message is correct except the line number. 
It should be line 10, not line 6. The problem is where the incorrect 
cast is performed, not where the enum is defined.

I just spent three hours on this problem (thanks to Idan. Otherwise I'd 
spend much much more).

Shachar


More information about the Digitalmars-d mailing list