Summary: Bogus Error message on const ref return
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD

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


Reply via email to