www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1599] New: compile time evaluation with invariant problem

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

           Summary: compile time evaluation with invariant problem
           Product: D
           Version: 2.006
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: braddr puremagic.com


This compiles:
template foo(A...) { invariant char[] foo = A[0]; }
static assert(foo!("a") == "a");

This doesnt:
template foo(A...) { invariant(char)[] foo = A[0]; }
static assert(foo!("a") == "a");

The error: static assert  (foo == "a") is not evaluatable at compile time

the difference is the ()'s around char, it's subtle. :)


-- 
Oct 19 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1599


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
            Summary|compile time evaluation     |compile time evaluation
                   |with invariant problem      |with immutable problem



The compiler doesn't give the normal 'invariant is deprecated' error message
for the first case. I think it's not running semantic() on it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 14 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1599


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



template foo(A...) { immutable(char)[] foo = A[0]; }
static assert(foo!("a") == "a");
----
vug.d(2): Error: variable foo cannot be read at compile time
vug.d(2):        while evaluating: static assert(foo == "a")


This is because foo is a mutable run-time array of immutable(char). Not a bug.

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