Thread overview |
---|
March 03, 2009 [Issue 2706] New: invalid template instantiation (and declaration?) is not rejected | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2706 Summary: invalid template instantiation (and declaration?) is not rejected Product: D Version: 1.033 Platform: PC OS/Version: Linux Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: tomas@famolsen.dk The following code doesn't make sense to me, yet DMD accepts it: module k; enum TYP { ch, c } class TypeBasic { int oo; /// Allocates an instance of TypeBasic and assigns it to typeName. template newTB(char[] typeName) { const newTB = mixin("new TypeBasic(TYP."~typeName~")"); } /// Initializes predefined types. static this() { newTB!("c"); newTB!("ch"); } this(int inp) { oo=inp; } } void main() { } I got this from a LDC bug report in IRC, and TBH I can't think anything but WTF is going on here? DMD seems to emit two 'new' expressions in the static ctor. I would think it should be: error: 'new TypeBasic(TYP.c)' is not a constant expression -- |
March 03, 2009 [Issue 2706] invalid template instantiation (and declaration?) is not rejected | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2706 ------- Comment #1 from tomas@famolsen.dk 2009-03-02 22:37 ------- Anoter test case: template newTB(char[] a, char[] b) { const newTB = mixin(a~"+"~b); } void main() { int a, b; auto c = newTB!("a", "b"); } Here the bogus error message: Error: Array operations not implemented is produced when it should be: Error: a + b is not a constant expression. or am I completely off here ? -- |
March 03, 2009 [Issue 2706] invalid template instantiation (and declaration?) is not rejected | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2706 ------- Comment #2 from tomas@famolsen.dk 2009-03-02 22:45 ------- Ok the second one makes a little sense. but what about this one: template newTB(char[] c, char[] d) { const newTB = mixin(c~"+"~d); } int a=1, b=2; void main() { auto c = newTB!("a", "b"); printf("%d\n", c); a = 4; b = 6; c = newTB!("a", "b"); printf("%d\n", c); } extern(C) int printf(char*, ...); /* [tomas@myhost tests]$ dmd bar.d [tomas@myhost tests]$ ./bar 3 10 */ ? -- |
April 14, 2011 [Issue 2706] invalid template instantiation (and declaration?) is not rejected | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2706 Don <clugdbug@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug@yahoo.com.au --- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-04-14 15:31:39 PDT --- Updated test case for D2.052: template newTB(string c, string d) { enum newTB = mixin(c~"+"~d); } int a=1, b=2; void main() { auto c = newTB!("a", "b"); a = 4; b = 6; c = newTB!("a", "b"); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 30, 2012 [Issue 2706] invalid template instantiation (and declaration?) is not rejected | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2706 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |yebblies@gmail.com Resolution| |DUPLICATE --- Comment #4 from yebblies <yebblies@gmail.com> 2012-01-30 17:23:06 EST --- *** This issue has been marked as a duplicate of issue 2526 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation