D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3338 - template "is not an expression", "of type void", and "is not evaluatable at compile time" combo error.
Summary: template "is not an expression", "of type void", and "is not evaluatable at c...
Status: RESOLVED DUPLICATE of issue 7363
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-22 00:52 UTC by Chad Joan
Modified: 2015-06-09 01:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Chad Joan 2009-09-22 00:52:54 UTC
[code]
template ouch(alias members)
{
    static if ( members.length == 0 )
    {
        const bool ouch = true;
    }
    else
    {
        // If you want to compile successfully, just comment out this one line.
        enum foo = "sup.";

        // Commenting the true removes the "is not an expression" error.
        // Commenting out the recursion leaves only the
        //     "is not evaluatable at compile time" error.
        // Reversing the order has the same effect as removing the true.
        // See what combinations YOU can come up with! ;)
        const bool ouch =
            true &&
            ouch!(members[1..$]);
    }
}

static assert( ouch!(["a","b"]) );

void main() {}
[/code]

As the comments suggest, things can be altered slightly to change what error messages are produced.

The error messages it produces in its virgin (and most verbose form) are as follows:
[code]
main.d(16): Error: ouch!(["b"]) is not an expression
main.d(16): Error: cannot implicitly convert expression (!!ouch!(["b"])) of type void to const(bool)
main.d(21): Error: template instance main.ouch!(["a","b"]) error instantiating
main.d(21): Error: static assert  (ouch!(["a","b"])) is not evaluatable at compile time
[/code]

I'm actually not sure if it's supposed to be possible to pass string[]'s as alias parameters (passing them as straight string[]'s seems forbidden), but either way there is /something/ wrong.
Comment 1 Brad Roberts 2011-02-06 15:39:25 UTC
Mass migration of bugs marked as x86-64 to just x86.  The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.
Comment 2 yebblies 2012-02-03 23:42:04 UTC

*** This issue has been marked as a duplicate of issue 7363 ***