[Issue 2849] Length of a local immutable(char[]) cannot be a template value argument

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 25 08:06:50 PST 2012


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


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2012-12-25 08:06:48 PST ---
(In reply to comment #1)
> It's because it doesn't try to const fold it. In this case,
> the init value is constant, so it could possibly work. In other cases,
> it could be initialized from something non-constant (eg, a function
> parameter). Regardless, it should say that it's not constant, rather
> than just that it's not a valid template parameter.

That first sample now works, but w.r.t. errors I can't reproduce the bad error
message. E.g.:

struct bar (int n){}
void main()
{
    char[] x = "bug".dup;
    bar!(x.length) z;
}

test.d(5): Error: variable x cannot be read at compile time
test.d(5): Error: expression x.length is not a valid template value argument
test.d(5): Error: template instance test.bar!(x.length) error instantiating

Fixed?

-- 
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