From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Strange compile-time error with Ada.Containers.Indefinite_Hashed_Maps Date: Mon, 19 May 2014 14:49:45 +0100 Organization: A noiseless patient Spider Message-ID: References: <9d912199-ff00-403f-b6e3-fb9632ec145e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="942b5624700b15f09a730d9ed9406bd7"; logging-data="11899"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lH3ugPC2IZT2gMTE89gBT8MMjosXIabI=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:anatnJv0axL5EvorsUPFI9tPIWs= sha1:rOBrRtILZjgwhoBHmvF6crTmvOk= Xref: news.eternal-september.org comp.lang.ada:19898 Date: 2014-05-19T14:49:45+01:00 List-Id: mockturtle writes: > I define the "identifier name" type in a package that is with-ed by > the package that defines the symbol table. The symbol table is just a > Indefinite_Hash_Map (indefinite since the descriptor is indefinite). > When I try to compile the body of the symbol table package I get in > the .ads the error > > instantiation error at a-cihama.adb:1043 > invalid constraint: type has no discriminant All of GNAT GPL 2013, FSF GCC 4.8.1 and FSF GCC 4.9.0 are happy with your code. a-cihama.adb (Ada.Containers.Indefinite_Hashed_Maps) line 1043 is in Read_Node: function Read_Node (Stream : not null access Root_Stream_Type'Class) return Node_Access is Node : Node_Access := new Node_Type; begin begin Node.Key := new Key_Type'(Key_Type'Input (Stream)); <<<<<< and I don't see why GNAT thinks there (should be?) a discriminant there. Is there a reason why you don't make Name_Type just String? You're forced to use indefinite hashed maps, so the stored Key is assumed to be indefinite and will be allocated. (I tried this and the compiler was happy).