Type programming game

Stefan Koch uplink.coder at googlemail.com
Tue Oct 27 16:13:12 UTC 2020


On Wednesday, 14 October 2020 at 11:14:34 UTC, Stefan Koch wrote:
> On Wednesday, 14 October 2020 at 00:11:37 UTC, claptrap wrote:
>> On Tuesday, 13 October 2020 at 14:43:23 UTC, Stefan Koch wrote:
>>> On Monday, 12 October 2020 at 14:04:56 UTC, claptrap wrote:
>>> I fixed your version to work around the bugs in type 
>>> functions.
>>> [...]
>> Yeah not as concise as it could be, but I assume eventually 
>> type[idx] will work outside assign expressions?
>
> Yes of course.

So it turns out not to be the type-array[idx] in general.
That works as expected.
However when it's used inside an is expression.
The is-expression's type gets evaluated _before_ executes the 
type function ctfe
And during that time type-array[idx] is not parsed as variable 
expression.
it's parsed as the type of a static array, and assuming that idx 
is an enum with numeric values
so given enum idx := 6;
type-array[6] is the type of static array.

I am still thinking about how to fix this.


More information about the Digitalmars-d mailing list