[comp.lang.eiffel] What is this error?

jellinghaus-robert@CS.Yale.EDU (Rob Jellinghaus) (03/10/89)

I don't expect to get a reply to this in time to be of any help to me,
but I'll ask anyway.  I'm working on my hash table class (recall that
I have a deferred class HASHABLE defining features hash:integer and
same:boolean, which must be inherited from to use the class).  I've
got it written, and it compiles almost all the way through, except then
it says

Eiffel configuration manager
	 (version 2.1)
Pass 4 on class hash_table
"hash_table", 78: p4/type4.c: Datum_macro (): unknown basic type for an attribute: B0
Please send information regarding this error
to Interactive Software Engineering.
-------------------------------------------------

*** es: error in pass4

What kind of information should I send?  What could I be doing wrong?
The error occurs in a very simple routine:

	index(x: T) is
			-- x's index in array
		do
			Result := x.hash mod size
				-- random hash function
		ensure
			0 <= Result; Result < size
		end;

which simply asks the datum to hash itself, and then converts that number
to be within the bounds of the hash table.  And, you guessed it, the line
beginning "Result :=" is line 78.

And this is only the first class I've ever tried to build with Eiffel.
Needless to say, I am very disappointed.

Rob Jellinghaus                | "Next time you see a lie being spread or a
jellinghaus-robert@CS.Yale.EDU |  bad decision being made out of sheer ignor-
ROBERTJ@{yalecs,yalevm}.BITNET |  ance, pause, and think of hypertext."
{everyone}!decvax!yale!robertj |     -- K. Eric Drexler, _Engines of Creation_

keithc@cognos.uucp (Keith Campbell) (03/11/89)

In article <53250@yale-celray.yale.UUCP> jellinghaus-robert@CS.Yale.EDU (Rob Jellinghaus) writes:
>Pass 4 on class hash_table
>"hash_table", 78: p4/type4.c: Datum_macro (): unknown basic type for an attribute: B0

We have run into this one at Cognos as well.  The problem is that you forgot
to declare the type of Result.  We too were disappointed.

Change
>	index(x: T) is
to
	index( x : T ) : Integer IS

-- 
Keith Campbell               Cognos Incorporated   S-mail: P.O. Box 9707
Voice: (613) 738-1338 x5222                                3755 Riverside Drive
  FAX: (613) 738-0002                                      Ottawa, Ontario
 UUCP: uunet!mitel!sce!cognos!keithc                       CANADA  K1G 3Z4

bertrand@eiffel.UUCP (Bertrand Meyer) (03/13/89)

From article <53250@yale-celray.yale.UUCP>,
by jellinghaus-robert@CS.Yale.EDU (Rob Jellinghaus):

> I don't expect to get a reply to this in time to be of any help to me,
> but I'll ask anyway.

I agree. One should not expect too much; then surprises can only be
pleasant.

> [Reproduction of ``internal error'' message]
>
> What could I be doing wrong? [...] 
> The error occurs in a very simple routine:
> 
>     index(x: T) is [...]
>         do
>             Result := x.hash mod size  <--- [Error is detected here]
> 
> And this is only the first class I've ever tried to build with Eiffel.
> Needless to say, I am very disappointed.

I hope you try a few others. What you are doing wrong is to use
``Result'' in a routine declared as a procedure.
A routine that has a result should be declared as a function:

    index (x: T): INTEGER

Then everything will work fine.

The improper error message was due to lack of detection in pass 2;
then pass 4 would find something wrong but didn't know what happened,
hence the ``internal error'' message.

I am using the past tense because the problem was uncovered and
corrected some time ago; the ``internal error'' message doesn't
show up any more. Instead, a clear error message is printed during pass 2.
Of course, this is no consolation to someone (such as Mr. Jellinghaus)
whose system was shipped before this correction was made. The correction
is obviously included in the forthcoming 2.2 release.

Sorry for the inconvenience.

-- Bertrand Meyer