Exception in 1.2.8 but not in 1.2.1

Robert Staerk <[email protected]>
Newsgroups gmane.comp.gnu.prolog.bugs
Message-ID <[email protected]>
------------------------------------------------------------------------
Description of the problem (Sun-Sparc and PC-Redhat-Linux): 
------------------------------------------------------------------------
The following goal throws an exception in gprolog 1.2.8 and 1.2.12
but not in 1.2.1 (I didn't try other versions).

GNU Prolog 1.2.8

  ?- test(1+2,X).

  uncaught exception: error(type_error(evaluable,infix/3),(=<)/2)

GNU Prolog 1.2.1

  ?- test(1+2,X).

  X = i(+,a(1),a(2))
------------------------------------------------------------------------
uname -a
SunOS tomis 5.6 Generic_105181-17 sun4u sparc SUNW,Ultra-5_10

uname -a
Linux qed 2.4.9-12 #1 Tue Oct 30 18:33:49 EST 2001 i686 unknown
------------------------------------------------------------------------
Program used:
------------------------------------------------------------------------
test(A,Tree) :-
	test(A,1200,Tree).

test(A,Prec,Tree) :-
	(	atomic(A) ->
		Tree = a(A)
	;	A =.. L,
		test_list(L,Prec,Tree)
	).

test_list(L,Prec1,Tree4) :-
	L = [Name,A,B],
	infix_prec(Name,Prec2,Prec3,Prec4), !,
	test(A,Prec3,Tree1),
	test(B,Prec4,Tree2),
	Tree3 = i(Name,Tree1,Tree2),
	parenthesize(Prec1,Prec2,Tree3,Tree4).

parenthesize(Prec1,Prec2,Tree1,Tree2) :-
	(	Prec2 =< Prec1 ->
		Tree2 = Tree1
	;	Tree2 = p(Tree1)
	).

infix_prec(Op,Prec1,Prec2,Prec1) :-
	current_op(Prec1,xfy,Op),
	Prec2 is Prec1 - 1.
infix_prec(Op,Prec1,Prec1,Prec2) :- 
	current_op(Prec1,yfx,Op),
	Prec2 is Prec1 - 1.

------------------------------------------------------------------------
tomis>  gprolog
GNU Prolog 1.2.8
By Daniel Diaz
Copyright (C) 1999-2001 Daniel Diaz
| ?- [example].
compiling /home/staerk/cpc-1.03/example.pl for byte code...
/home/staerk/cpc-1.03/example.pl compiled, 30 lines read - 3979 bytes written,
69 ms

(10 ms) yes
| ?- test(1+2,X).
uncaught exception: error(type_error(evaluable,i/3),(=<)/2)
| ?- trace.
The debugger will first creep -- showing everything (trace)

yes
{trace}
| ?- test(1+2,X).
      1    1  Call: test(1+2,_18) ? 
      2    2  Call: test(1+2,1200,_18) ? 
      3    3  Call: atomic(1+2) ? 
      3    3  Fail: atomic(1+2) ? 
      3    3  Call: 1+2=.._112 ? 
      3    3  Exit: 1+2=..[+,1,2] ? 
      4    3  Call: test_list([+,1,2],1200,_18) ? 
      5    4  Call: infix_prec(+,_170,_171,_172) ? 
      6    5  Call: current_op(_195,xfy,+) ? 
      6    5  Fail: current_op(_183,xfy,+) ? 
      6    5  Call: current_op(_195,yfx,+) ? 
      6    5  Exit: current_op(500,yfx,+) ? 
      7    5  Call: _223 is 500-1 ? 
      7    5  Exit: 499 is 500-1 ? 
      5    4  Exit: infix_prec(+,500,500,499) ? 
      8    4  Call: test(1,500,_250) ? 
      9    5  Call: atomic(1) ? 
      9    5  Exit: atomic(1) ? 
      8    4  Exit: test(1,500,a(1)) ? 
     10    4  Call: test(2,499,_302) ? 
     11    5  Call: atomic(2) ? 
     11    5  Exit: atomic(2) ? 
     10    4  Exit: test(2,499,a(2)) ? 
     12    4  Call:
parenthesize(1200,d(12,[a(parenthesize(1200,d(12,[a(parenthesize(1200,d(...,...),...),12,4,...),a(test_list(...,...),4,...),a(...,...),...]),i(+,a(1),a(2)),_18),12,4,249),a(test_list([+,1,2],1200,_18),4,3,196),a(test(1+2,1200,_18),2,2,143),a(test(1+2,_18),1,1,87)]),i(+,a(1),a(2)),_18)
? 
     13    5  Call:
d(13,[a(d(13,[a(d(...,...)=<1200,13,5,...),a(parenthesize(...,...),12,...),a(...,...),...])=<1200,13,5,336),a(parenthesize(1200,d(13,[a(...
=<
...,13,...),a(...,...),...]),i(+,a(1),a(2)),_18),12,4,249),a(test_list([+,1,...],1200,_18),4,3,196),a(test(1+2,1200,_18),2,2,143),a(test(...
+ ...,_18),1,1,...)])=<1200 ? 
     13    5  Exception:
d(13,[a(d(13,[a(d(...,...)=<1200,13,5,...),a(parenthesize(...,...),12,...),a(...,...),...])=<1200,13,5,336),a(parenthesize(1200,d(13,[a(...
=<
...,13,...),a(...,...),...]),i(+,a(1),a(2)),_18),12,4,249),a(test_list([+,1,...],1200,_18),4,3,196),a(test(1+2,1200,_18),2,2,143),a(test(...
+ ...,_18),1,1,...)])=<1200 ? 
     12    4  Exception:
parenthesize(1200,d(12,[a(parenthesize(1200,d(12,[a(parenthesize(1200,d(...,...),...),12,4,...),a(test_list(...,...),4,...),a(...,...),...]),i(+,a(1),a(2)),_18),12,4,249),a(test_list([+,1,2],1200,_18),4,3,196),a(test(1+2,1200,_18),2,2,143),a(test(1+2,_18),1,1,87)]),i(+,a(1),a(2)),_18)
? 
      4    3  Exception: test_list([+,1,2],1200,_18) ? 
      2    2  Exception: test(1+2,1200,_18) ? 
      1    1  Exception: test(1+2,_18) ? 
uncaught exception: error(type_error(evaluable,d/2),(=<)/2)
{trace}
| ?- 
------------------------------------------------------------------------
Line 12 looks strange to me.
------------------------------------------------------------------------

--------------------------------------------------------
Robert F. Staerk                   (St\"ark, St&auml;rk)
Theoretische Informatik             phone: +41 1 6327970
ETH Zentrum                           fax: +41 1 6321478
CH-8092 Zuerich           http://www.inf.ethz.ch/~staerk
--------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.