[m-dev.] diff: fix bug in pprint__to_doc
Fergus Henderson
fjh at cs.mu.OZ.AU
Tue May 9 22:40:29 AEST 2000
Estimated hours taken: 0.5
library/pprint.m:
Fix a bug: there was an infinite loop in the code for `to_doc'.
The recursive call to convert the term's arguments was
happening even in the case where the term had no arguments.
Workspace: /home/pgrad/fjh/ws/hg
Index: library/pprint.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/pprint.m,v
retrieving revision 1.1
diff -u -d -r1.1 pprint.m
--- library/pprint.m 2000/05/03 09:56:46 1.1
+++ library/pprint.m 2000/05/09 12:13:25
@@ -454,25 +454,25 @@
% This may throw an exception or cause a runtime abort if the term
% in question has user-defined equality.
-to_doc(Depth, X) =
+to_doc(Depth, X) = Doc :-
+ deconstruct(X, Name, Arity, UnivArgs),
( if Arity = 0 then
- text(Name)
+ Doc = text(Name)
else if Depth =< 0 then
- text(Name) `<>` text("(...)")
+ Doc = text(Name) `<>` text("(...)")
else
- text(Name) `<>`
- parentheses(
- group(
- nest(2, line `<>` separated(id, comma_space_line, Args)) `<>`
- line
+ Args = list__map(
+ ( func(UnivArg) = to_doc(Depth - 1, univ_value(UnivArg)) ),
+ UnivArgs
+ ),
+ Doc = text(Name) `<>`
+ parentheses(
+ group(
+ nest(2,
+ line `<>` separated(id, comma_space_line, Args)
+ ) `<>` line
+ )
)
- )
- )
-:-
- deconstruct(X, Name, Arity, UnivArgs),
- Args = list__map(
- ( func(UnivArg) = to_doc(Depth - 1, univ_value(UnivArg)) ),
- UnivArgs
).
%------------------------------------------------------------------------------%
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list