[Issue 4397] const/CTFE does not work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 19 04:51:18 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=4397



--- Comment #15 from Don <clugdbug at yahoo.com.au> 2013-03-19 04:51:15 PDT ---
It passes if you specify the type in the const/enum.

The reason is, that in declaration.c, VarDeclaration::semantic(), we see this
code:

else if (storage_class & (STCconst | STCimmutable | STCmanifest) ||
                 type->isConst() || type->isImmutable())
        {
            /* Because we may need the results of a const declaration in a
             * subsequent type, such as an array dimension, before semantic2()
             * gets ordinarily run, try to run semantic2() now.
             * Ignore failure.
             */
            if (!global.errors && !inferred)
                 ....

If we're inferring type inference, then semantic2 doesn't get run on the
variable declaration (cX in the original bug report).

So when it runs semantic on "return cx;", DsymbolExp::semantic() for cx,
returns cx->init, which hasn't had semantic run on it yet. So it behaves like a
copy-and-paste of the initializer.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list