digitalmars.D - Compiler bug: Incorrect line in error message
- Shachar Shemesh (18/18) Jan 14 2018 Please consider the following program:
- Shachar Shemesh (4/29) Jan 14 2018 Reported as issue #18236
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
Jan 14 2018
(opened on D1). On 14/01/18 14:24, Shachar Shemesh wrote: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
Jan 14 2018