www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3338] New: template "is not an expression", "of type void", and "is not evaluatable at compile time" combo error.

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

           Summary: template "is not an expression", "of type void", and
                    "is not evaluatable at compile time" combo error.
           Product: D
           Version: 2.032
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: chadjoan gmail.com


--- Comment #0 from Chad Joan <chadjoan gmail.com> 2009-09-22 00:52:54 PDT ---
[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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 22 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3338


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|x86_64                      |x86


--- Comment #1 from Brad Roberts <braddr puremagic.com> 2011-02-06 15:39:25 PST
---
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.

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