www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Integer constant expression expected instead of...

reply "Era Scarecrow" <rtcvb32 yahoo.com> writes:
[code]
   enum fieldEntryLength = 4;
   //immutable fieldEntryLength = 4; //same issue
   alias immutable(char[fieldEntryLength]) NString;
[/code]

test.d(10): Error: Integer constant expression expected instead 
of fieldEntryLength


  This breaks code that previously compiled. I really don't see 
the problem... bug?

  Version: Windows DMD32 D Compiler v2.063.2
Sep 01 2013
parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Era Scarecrow:

 [code]
   enum fieldEntryLength = 4;
   //immutable fieldEntryLength = 4; //same issue
   alias immutable(char[fieldEntryLength]) NString;
 [/code]

 test.d(10): Error: Integer constant expression expected instead 
 of fieldEntryLength


  This breaks code that previously compiled. I really don't see 
 the problem... bug?
It could be a regression. You could file it in Bugzilla. In the meantime this seems to work (I have also used the new alias syntax. Eventually the old alias syntax should be deprecated): enum fieldEntryLength = 4; alias NString = immutable(char)[fieldEntryLength]; Bye, bearophile
Sep 01 2013
next sibling parent "Era Scarecrow" <rtcvb32 yahoo.com> writes:
On Monday, 2 September 2013 at 01:19:44 UTC, bearophile wrote:
 Era Scarecrow:
 [code]
  enum fieldEntryLength = 4;
  //immutable fieldEntryLength = 4; //same issue
  alias immutable(char[fieldEntryLength]) NString;
 [/code]

 test.d(10): Error: Integer constant expression expected 
 instead of fieldEntryLength
It could be a regression. You could file it in Bugzilla. In the meantime this seems to work (I have also used the new alias syntax. Eventually the old alias syntax should be deprecated): enum fieldEntryLength = 4; alias NString = immutable(char)[fieldEntryLength];
alias NString = immutable(char)[fieldEntryLength]; //works alias NString = immutable(char[fieldEntryLength]); //fails I wonder why this is the case... It's a fixed number either way...
Sep 01 2013
prev sibling parent "Era Scarecrow" <rtcvb32 yahoo.com> writes:
Added:

http://d.puremagic.com/issues/show_bug.cgi?id=10946
Sep 01 2013