Bug 2728 – Bogus Error message on const ref return

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-03-11T11:43:00Z
Last change time
2015-06-09T05:15:07Z
Keywords
diagnostic
Assigned to
bugzilla
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2009-03-11T11:43:58Z
Version 2.026, not sure why that's not an option yet in the version list. struct Const { uint[2] num; ref uint opIndex(uint index) const { return num[index]; } } Error message by compiler: Error: cast(uint)(this.num[index]) is not an lvalue This may be technically correct if the compiler is trying to cast away const to return the reference, but the error message should really be related to the fact that you can't return a non-const reference here without violating const correctness.
Comment #1 by bugzilla — 2009-04-01T13:55:29Z
Fixed DMD 2.027