Thread overview
Integer constant expression expected instead of...
Sep 02, 2013
Era Scarecrow
Sep 02, 2013
bearophile
Sep 02, 2013
Era Scarecrow
Sep 02, 2013
Era Scarecrow
September 02, 2013
[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
September 02, 2013
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
September 02, 2013
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...
September 02, 2013
Added:

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