www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10511] New: Unhelpful error messages with a const opDispatch

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10511

           Summary: Unhelpful error messages with a const opDispatch
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



Modified from code by David in D.learn. This is wrong code:


struct Foo {
    static Foo opDispatch(string s)() const {
        return Foo();
    }
}
void main() {
    Foo f = Foo.bar();
}



DMD 2.064alpha gives:

test.d(7): Error: no property 'bar' for type 'Foo'
test.d(7): Error: Foo is not an expression


The error messages don't help much because they don't explain what's the
problem. The code able to compile is without "const":


struct Foo {
    static Foo opDispatch(string s)() {
        return Foo();
    }
}
void main() {
    Foo f = Foo.bar();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10511


Dicebot <m.strashun gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |m.strashun gmail.com



Why static const methods are allowed in the very first place? Is there a legit
use case?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 30 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10511





 Why static const methods are allowed in the very first place? Is there a legit
 use case?
I think it's a regression (maybe already reported in Bugzillza), because this code: const void foo() {} void main() {} Used to give: Error: function test.foo without 'this' cannot be const/immutable -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10511






 I think it's a regression (maybe already reported in Bugzillza),
It's Issue 10482 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013