January 14, 2018 Compiler bug: Incorrect line in error message | ||||
---|---|---|---|---|
| ||||
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 |
January 14, 2018 Re: Compiler bug: Incorrect line in error message | ||||
---|---|---|---|---|
| ||||
Posted in reply to Shachar Shemesh | Reported as issue #18236
It is possible this is a duplicate of issue #3773, from 8 years ago (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
|
Copyright © 1999-2021 by the D Language Foundation