www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13731] New: Wrong interpretation of const keyword when


          Issue ID: 13731
           Summary: Wrong interpretation of const keyword when creating
                     property returning class
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: buday48 mail.ru

class Foo

class Bar
    Foo foo_;
    Foo foo() const  property
        return this.foo_;      //<- Compilation Error

void main() {

DMD 2.066 gives an error message:

app.d(10): Error: cannot implicitly convert expression (this.foo_) of type
const(Foo) to app.Foo

const keyword is actually used to specify function foo() but not its type Foo

Nov 13 2014