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.232.229 with SMTP id tr5mr16153182pac.16.1399924061737; Mon, 12 May 2014 12:47:41 -0700 (PDT) X-Received: by 10.140.18.194 with SMTP id 60mr41687qgf.36.1399924061690; Mon, 12 May 2014 12:47:41 -0700 (PDT) Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!r10no3628716igi.0!news-out.google.com!dz10ni36309qab.1!nntp.google.com!hw13no2836620qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 12 May 2014 12:47:41 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=93.37.84.80; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 NNTP-Posting-Host: 93.37.84.80 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Weird error with Dynamic_Predicate From: mockturtle Injection-Date: Mon, 12 May 2014 19:47:41 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Original-Bytes: 3790 Xref: number.nntp.dca.giganews.com comp.lang.ada:186369 Date: 2014-05-12T12:47:41-07:00 List-Id: 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; ----