2012/5/31 Tommi <tommitiss...@hotmail.com>: > On Wednesday, 30 May 2012 at 15:04:40 UTC, kenji hara wrote: >> >> Looks like a bug. >> >> ValueUser.getValue() is translated to ValueUser.m_valueImpl.getValue() >> with alias this resolution. In here: >> 1. ValueUser.m_valueImpl is a valid expression. It means just a symbol >> of variable which declared in ValueUser struct. >> 2. ValueUser.m_valueImpl is only used for overload resolution of >> calling getValue() and getValue is static member function, then it is >> *never* evaluated even in run-time. >> >> Please file a report about it in bugzilla. >> >> Kenji Hara > > > Sorry, I'm not sure what you mean. Which one of the following is a bug? > > 1) The fact that ValueUser.getValue() can't be evaluated at compile time > 2) The fact that ValueUser.getValue() compiles and can be evaluated at > runtime > > I'm very new to the language. Just finished reading the book and I'm testing > things out.
Sorry for my poor English. I'd like to say that ValueUser.getValue() should be evaluated at compile time and runtime. First, we cannot evaluate ValueUser.m_valueImpl in compile time, but can *use* it in compile time. This is a case, using it in typeof expression. static assert(is(typeof(ValueUser.m_valueImpl) == ValueImpl)); Type comparison is compile time operation, then this works. Next, In the expression ValueUser.m_valueImpl.getValue() (equals to ValueUser.getValue()), ValueUser.m_valueImpl is just used to specify where the static function getValue is declared. We can rewrite it like as: typeof(ValueUser.m_valueImpl).getValue() So ValueUser.m_valueImpl is used in compile time, but not evaluated. Therefore original error message is wrong because compiler should not try to evaluate ValueUser.m_valueImpl in compile time. Kenji Hara