Why doesn't this have a length?

Simen Kjærås simen.kjaras at gmail.com
Mon Mar 12 19:27:46 PDT 2012


On Mon, 12 Mar 2012 19:20:07 +0100, Andrej Mitrovic  
<andrej.mitrovich at gmail.com> wrote:

> On 3/12/12, Ali Çehreli <acehreli at yahoo.com> wrote:
>> Let's please also see the exact error message. "an error message that
>> seems to indicate that DMD is looking for a global identifier" is not
>> clear to mortals like myself. :)
>
> He probably means something like this:
>
> struct State { }
> struct Input { }
> State[][Tuple!(const(State), const(Input))] transitions;
>
> void main() {
>     writeln(transitions.length);
> }
>
> test.d(20): Error: undefined identifier module test.length
>
> Note that typeid doesn't work either:
> writeln(typeid(transitions));
> D:\DMD\dmd2\windows\bin\..\..\src\druntime\import\object.di(507):
> Error: can only initialize const member key inside constructor
>
> This seems to be an issue related with const. Without const both calls  
> work.

Weird. You get a different error message from what I get.
My reduced code:

struct Bar {
	const int t;
}

void main( ) {
	int[Bar] a;
	int n = a.length;
}

Error message:

Assertion failure: 'impl' on line 4407 in file 'mtype.c'

abnormal program termination

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


More information about the Digitalmars-d-learn mailing list