digitalmars.D.bugs - [Issue 2210] New: Error: void initializer has no value
- d-bugmail puremagic.com (19/19) Jul 09 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2210
- d-bugmail puremagic.com (15/15) Jul 09 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2210
- d-bugmail puremagic.com (6/6) Jul 09 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2210
- d-bugmail puremagic.com (35/35) Jul 09 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2210
- d-bugmail puremagic.com (7/7) Jul 09 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2210
http://d.puremagic.com/issues/show_bug.cgi?id=2210 Summary: Error: void initializer has no value Product: D Version: 1.032 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: moritzwarning web.de template isStaticArrayTypeInst( T ) { const T isStaticArrayTypeInst = void; } Compile error: Error: void initializer has no value --
Jul 09 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2210 Please, do not hurry in posting your bug report! The piece of code itself doesn't have any issues. I think the issue you are talking about is this: template instance(T) { const T instance = void; } void main() { int i = instance!(char[]).length; // works at runtime const int i = instance!(char[]).length; // doesn't work at compile time } I can not judge whether it is a correct behavior or not. It just worked before but doesn't anymore. --
Jul 09 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2210 Right, I was in a hurry. Sorry for that. Anyway, it looks like it's no dmd bug, since the length property would be undefined at runtime. The same should apply at compile time. --
Jul 09 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2210 I'm sorry, I didn't investigate problem deep enough. Issue is completely different. Let's start with a bachground, first. The following template is used to work prior to DMD1.032 release: private template isStaticArrayTypeInst( T ) { const T isStaticArrayTypeInst = void; } /** * Evaluates to true if T is a static array type. */ template isStaticArrayType( T ) { static if( is( typeof(T.length) ) && !is( typeof(T) == typeof(T.init) ) ) { const bool isStaticArrayType = is( T == typeof(T[0])[isStaticArrayTypeInst!(T).length] ); } else { const bool isStaticArrayType = false; } } But now it doesn't. I reduced the test case to the following difference: template Test( T ) { const bool Test = ( is( typeof(T) == typeof(T.init) ) ); } void main() { static assert( Test!(int) ); } This asserts succeeded in DMD1.031 and fails in DMD1.032. As you see, it's a typeof(int) issue, that was discussed last days. That's it. --
Jul 09 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2210 moritzwarning web.de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --
Jul 09 2008