D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 15089 - Marks wrong line as where error occurs.
Summary: Marks wrong line as where error occurs.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: diagnostic
: 12337 15090 (view as issue list)
Depends on:
Blocks:
 
Reported: 2015-09-20 17:58 UTC by James
Modified: 2017-07-21 10:44 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description James 2015-09-20 17:58:24 UTC
Code:
enum Pieces : ubyte
{
  Empty,
  Pawn,
  Rook,
  Knight,
  Bishop,
  Queen,
  King
}

int color = 0b10000000;

...

byte[64] pieces;

...

pieces[i] = color ^ Pieces.Rook;

Explanation:
The compiler marked the error as occurring in the enum saying that 129 was too large to store in a byte when the error should have occurred in the last line where 129 was actually being assigned to a byte value.
Comment 1 ag0aep6g 2015-09-20 18:20:54 UTC
Thanks for reporting. You reduced/edited the code a bit too much. It doesn't actually show the problem anymore. But don't worry, I got you.

Here's reduced code that still shows the wrong error message:

----
enum Pieces {Rook} /* line 1 */
immutable int color = 0b10000000;
byte piece = Pieces.Rook ^ color;
----
test.d(1): Error: cannot implicitly convert expression (128) of type int to byte
----

For reference, this originated at Stack Overflow:
http://stackoverflow.com/questions/32681660/compiler-thinks-enum-values-are-starting-at-129
Comment 2 ag0aep6g 2015-09-20 19:07:54 UTC
*** Issue 15090 has been marked as a duplicate of this issue. ***
Comment 4 github-bugzilla 2015-09-21 00:28:46 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e2a7a3a41bf63b7096b7ad844bb47dcf578b9743
fix Issue 15089 - Marks wrong line as where error occurs.

https://github.com/D-Programming-Language/dmd/commit/d26cf5f2ae73b2d7e7b21c9af8716e1a931c5873
Merge pull request #5106 from WalterBright/fix15089

fix Issue 15089 - Marks wrong line as where error occurs.
Comment 5 Vladimir Panteleev 2017-07-21 10:41:13 UTC
*** Issue 12337 has been marked as a duplicate of this issue. ***
Comment 6 Vladimir Panteleev 2017-07-21 10:44:10 UTC
This was a regression, introduced in https://github.com/dlang/dmd/pull/2136.