On 2010-07-26 14:27, Rory Mcguire wrote:
Hi,

I'm not sure this is in bugzilla, I tried finding something mentioning it
but coudn't.

Compiling the below code results in the dmd compiler printing:
struct_bad_error.d(8): Error: 'this' is only defined in non-static member
functions, not inner

====================
struct S {
        S opCall() {S s; return s;}
}
void main() {
        S s;
        //s = S(); // decent error message: "struct_bad_error.d(6):
                // Error: need 'this' to access member opCall"
        void inner() {
                s = S();
        }
}
=====================

What to do? Also found that having an empty () after the struct name is not
the best error message: "struct_bad_error.d(5): Error: struct
struct_bad_error.S() is used as a type"

Surely it could tell me I need to put an Identifier in the ()

-Rory

Perhaps you want a static opCall ?

S foo;
foo(); // calls opCall
S(); // calls static opCall

--
/Jacob Carlborg

Reply via email to