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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.230.226 with SMTP id tb2mr11985583pac.41.1399928492937; Mon, 12 May 2014 14:01:32 -0700 (PDT) X-Received: by 10.50.78.195 with SMTP id d3mr549304igx.17.1399928492795; Mon, 12 May 2014 14:01:32 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!c1no5320712igq.0!news-out.google.com!gi6ni851igc.0!nntp.google.com!c1no5320707igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 12 May 2014 14:01:32 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3f9e21b4-868d-44de-9673-824eefb9e79e@googlegroups.com> Subject: Re: Weird error with Dynamic_Predicate From: Adam Beneschan Injection-Date: Mon, 12 May 2014 21:01:32 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:19790 Date: 2014-05-12T14:01:32-07:00 List-Id: For what it's worth, here's the smallest reduced example I can come up with that gives the same error message: package Prova is type Identifier_Name is new String with Dynamic_Predicate => true; function Extract_Namespace (Nome : Identifier_Name) return Identifier_Name; end Prova; package body Prova is function Extract_Namespace (Nome : Identifier_Name) return Identifier_Name is Idx : Natural := Ada.Strings.Fixed.Index (String (Nome), "."); begin return "ns"; end Extract_Namespace; end Prova; This is with GCC 4.5.4 (20120510). -- Adam On Monday, May 12, 2014 12:47:41 PM UTC-7, mockturtle wrote: > Dear all, > > I am experiencing an error that is making me crazy and I was wondering if someone can help. > > > > Some background: I want to define a type that represents an "identifier." The identifier can assume two forms: > > - qualified (es. namespace.foo) > > - not qualified (es. foo) > > > > The two components (namespace and name) have the usual syntax (letters, digits and underscore). Note that there are at most two components. I want to use the aspect Dynamic_Predicate to enforce (and document) the right syntax. > > > > You can find prova.ads and prova.adb at the end of this message. I am using GPS 5.2.1 (20130102) and when I try to compile I get the obscure message > > > > 29:32 error: conversion to incomplete type > > 29:32 confused by earlier errors, bailing out > > > > on >> prova.ads <<. If I try to do "check semantic" on prova.ads and prova.adb, everything is fine. > > > > > > Any ideas? Is it a compiler bug or am I doing something wrong? Updating the compiler in this moment it would be a little pain for me (for several reasons), so I would like to be sure that I am not doing some subtle error before trying the update path. > > > > Thank you in advance > > > > Riccardo > > > > > > > > --- prova.ads --- > > with Ada.Characters.Handling; use Ada.Characters.Handling; > > with Ada.Strings.Fixed; > > > > package Prova is > > type Identifier_Name is new > > String > > with Dynamic_Predicate => > > ((for all I in Identifier_Name'Range => > > Is_Alphanumeric (Identifier_Name (I)) > > or Identifier_Name (I) = '_' > > or Identifier_Name (I) = '.') > > and > > (not (Identifier_Name (Identifier_Name'First) in '0' .. '9')) > > and > > (Identifier_Name (Identifier_Name'First) /= '.') > > and > > Ada.Strings.Fixed.Count (String (Identifier_Name), ".") <= 1); > > > > function Is_Qualified (Item : Identifier_Name) return Boolean > > is (Ada.Strings.Fixed.Count (String (Item), ".") = 1); > > > > subtype Namespace_Identifier is Identifier_Name > > with Dynamic_Predicate => not Is_Qualified (Namespace_Identifier); > > > > subtype Full_Identifier is Identifier_Name > > with Dynamic_Predicate => Is_Qualified (Full_Identifier); > > > > > > function Extract_Namespace (Nome : Full_Identifier) > > return Namespace_Identifier; > > > > end Prova; > > > > --- prova.adb --- > > > > package body Prova is > > > > > > ----------------------- > > -- Extract_Namespace -- > > ----------------------- > > > > function Extract_Namespace (Nome : Full_Identifier) > > return Namespace_Identifier > > is > > Idx : Natural := Ada.Strings.Fixed.Index (String (Nome), "."); > > begin > > return Namespace_Identifier (Nome (Nome'First .. Idx - 1)); > > end Extract_Namespace; > > > > end Prova; > > ----