Thread overview |
---|
July 09, 2008 [Issue 2210] New: Error: void initializer has no value | ||||
---|---|---|---|---|
| ||||
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 -- |
July 09, 2008 [Issue 2210] Error: void initializer has no value | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2210 ------- Comment #1 from 2korden@gmail.com 2008-07-09 11:10 ------- 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. -- |
July 09, 2008 [Issue 2210] Error: void initializer has no value | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2210 ------- Comment #2 from moritzwarning@web.de 2008-07-09 11:26 ------- 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. -- |
July 09, 2008 [Issue 2210] Error: void initializer has no value | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2210 ------- Comment #3 from 2korden@gmail.com 2008-07-09 11:34 ------- 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. -- |
July 09, 2008 [Issue 2210] Error: void initializer has no value | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2210 moritzwarning@web.de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID -- |
Copyright © 1999-2021 by the D Language Foundation