[comp.lang.modula3] STextTable bug?

Dave Hanson <drh@Princeton.EDU> (06/11/91)

is the outcome below a bug in STextTable?
it appears to me that STable compares keys with NIL
and that TexT.Compare no longer accepts NIL arguments
(did it ever?).

or perhaps i've made some (obvious) error in using
STexTTable?


elan 344 cat Main.m3
MODULE Main;
IMPORT STextTable;

VAR     tab := STextTable.New();
        count: REF INTEGER;
BEGIN
        count := NEW(REF INTEGER);
        count^ := 1;
        EVAL STextTable.Put(tab, "foo", count)
END Main.
elan 345 m3 Main.m3 -lm3data
elan 346 a.out
M3 runtime error: Text.Compare: NIL argument

Quit (core dumped)
elan 347 

kalsow (Bill Kalsow) (06/11/91)

Yes, it's a bug in STextTable.  It calls Text.Compare with
NIL arguments.   The language report specifies that passing
NIL to any procedure in the Text interface is a checked runtime
error.  Early releases of SRC Modula-3 didn't adhere to this
piece of the specification.  Version 1.6 does.  We'll fix
STextTable for the next release.

Thanks for the bug report.

  - Bill Kalsow

goldberg@parc.xerox.com (David Goldberg) (06/12/91)

This bug has been addressed earlier:


Date: 	Mon, 1 Apr 1991 18:00:12 PST
From: muller@src.dec.com (Eric Muller)
Subject: SRC-M3 1.6: bug in STextTable.
To: modula3.parc@xerox.com

Norman Ramsey and David Golberg reported that STextTable sometime
fails with a runtime error in Text.Compare. 

The Text module now implements its interface properly, i.e. it
complains when a NIL Text.T is passed to one of the Text routines.

Unfortunately I failed to modify all the clients of Text so that they
do not call Text.xxx with a NIL Text.T. 

Here is a version of STextTable.Compare that will do the right thing:

	PROCEDURE Compare (arg: REFANY; key1, key2: STable.Key): INTEGER =
	  BEGIN
	    IF key1 = NIL THEN key1 := ""; END;
	    IF key2 = NIL THEN key2 := ""; END;
	    RETURN Text.Compare (key1, key2)
	  END Compare;

Thanks to Norman and David for reporting this bug.

-- 
Eric.