Bug 15089 – Marks wrong line as where error occurs.

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-09-20T17:58:00Z
Last change time
2017-07-21T10:44:10Z
Keywords
diagnostic
Assigned to
nobody
Creator
jjohnsonjj1251

Comments

Comment #0 by jjohnsonjj1251 — 2015-09-20T17:58:24Z
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 by ag0aep6g — 2015-09-20T18:20:54Z
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 by ag0aep6g — 2015-09-20T19:07:54Z
*** Issue 15090 has been marked as a duplicate of this issue. ***
Comment #3 by bugzilla — 2015-09-20T23:13:10Z
Comment #4 by github-bugzilla — 2015-09-21T00:28:46Z
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 by dlang-bugzilla — 2017-07-21T10:41:13Z
*** Issue 12337 has been marked as a duplicate of this issue. ***
Comment #6 by dlang-bugzilla — 2017-07-21T10:44:10Z
This was a regression, introduced in https://github.com/dlang/dmd/pull/2136.