www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1456] New: Cannot use a constant with alias template parameters

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

           Summary: Cannot use a constant with alias template parameters
           Product: D
           Version: 1.020
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: samukha voliacable.com


<code>
const int i = 20;

template Foo(alias bar)
{
}

alias Foo!(i) foo;
</code>
Error: template instance Foo!(20) does not match any template declaration

Please note that the compiler handles the situation correctly
if the initializer for i is left out:

<code>
const int i;

template Foo(alias bar)
{
  alias bar Foo;
}

alias Foo!(i) foo;
pragma(msg, foo.stringof); // now foo is aliased to i as expected
</code>

D 2.0 has the same problem.


-- 
Aug 30 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1456





------- Comment #1 from clugdbug yahoo.com.au  2007-09-13 07:22 -------
I don't think this is a bug. In the second case, the value of i is not known
until runtime. It's really just a variable. But the first case  is identical to

alias Foo!(20) foo;

which shouldn't compile.


-- 
Sep 13 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1456





------- Comment #2 from samukha voliacable.com  2007-09-13 09:26 -------
But in the first example the global name i and not 20 is aliased. It is
according to the specs. If it's not a bug, I would expect the following not to
work either:

const int i = 20;
alias i j; // Should fail with an error like "cannot alias 20 to j"? 


-- 
Sep 13 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1456


Max Samukha <samukha voliacable.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|blocker                     |normal


--- Comment #3 from Max Samukha <samukha voliacable.com> 2009-10-21 01:09:41
PDT ---
Not a blocker but still a bug, IMO. dmd 2.035 handles it right.

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