digitalmars.D.bugs - [Issue 1456] New: Cannot use a constant with alias template parameters
- d-bugmail puremagic.com (33/33) Aug 30 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1456
- d-bugmail puremagic.com (7/7) Sep 13 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1456
- d-bugmail puremagic.com (8/8) Sep 13 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1456
- d-bugmail puremagic.com (10/10) Oct 21 2009 http://d.puremagic.com/issues/show_bug.cgi?id=1456
- d-bugmail puremagic.com (12/12) Nov 21 2012 http://d.puremagic.com/issues/show_bug.cgi?id=1456
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
http://d.puremagic.com/issues/show_bug.cgi?id=1456 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
http://d.puremagic.com/issues/show_bug.cgi?id=1456 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
http://d.puremagic.com/issues/show_bug.cgi?id=1456
Max Samukha <samukha voliacable.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|blocker |normal
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
http://d.puremagic.com/issues/show_bug.cgi?id=1456
Don <clugdbug yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
This is not a bug. The reason it works in D2 is that D2 allows expressions as
template alias parameters.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 21 2012









d-bugmail puremagic.com 