MathAction #370 Improper code emmited by mkUnionFunList, impacts defintrf.spad



#370 Improper code emmited by mkUnionFunList, impacts defintrf.spad
last edited 17 years ago by kratt6

Submitted by : (unknown) at: 2007年11月17日T22:34:02-08:00 (18 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :
Optional comment :

In defintrf.spad, function findRealZero, we have the following code:

 select_!(keeprec?(i.halfinf.endpoint, #1), l)

The call to keeprec? gets lifted into a top level DEFUN in the generated Lisp but the Union/Record tags are being confused with free variables. This results in the following Lisp code (thanks to Gregory Vanuxem for pointing this out):

 (SPADCALL 
 (CONS #'|DFINTTLS;findRealZero!1|
 (VECTOR $ |dir| |endpoint| |i|)) ...)

As the tags |dir| and |endpoint| have been confused with free variables, the Lisp code now references unbound symbols.

A fix is to ensure that the code emmited when accessing a Union field properly macroexpands type expressions so that tags are explicitly quoted, and this recognized by the compiler as literals rather than evalable identifiers. This amounts to the following change in buildom.boot.pamphlet, in the functions mkUnionFunList and mkNewUnionFunList:

 --- buildom.boot.pamphlet 2007年07月08日 14:29:00.000000000 -0400
 +++ buildom.boot.pamphlet.sxw 2007年07月08日 14:29:34.000000000 -0400
 @@ -318,7 +318,7 @@
 ['XLAM,["#1"],['PROG1,['QCDR,"#1"],
 ['check_-union,['QEQCAR,"#1",i],type,"#1"]]]
 ['XLAM,["#1"],['PROG2,['LET,gg,"#1"],['QCDR,gg],
 - ['check_-union,['QEQCAR,gg,i],type,gg]]]
 + ['check_-union,['QEQCAR,gg,i],MACROEXPAND type,gg]]]
 [cList,e]
 mkEnumerationFunList(nam,['Enumeration,:SL],e) ==
 @@ -361,7 +361,7 @@
 ref:=gg
 q:= substitute(gg,"#1",p)
 ['XLAM,["#1"],['PROG2,['LET,gg,"#1"],ref,
 - ['check_-union,q,t,gg]]]
 + ['check_-union,q,MACROEXPAND t,gg]]]
 downFun() ==
 p is ['EQCAR,x,.] =>
 ['XLAM,["#1"],['QCDR,"#1"]]

On 08 Jul 2007 14:48:27 -0400 Stephen Wilson wrote:

The MACROEXPAND fix as detailed in a prior email seems workable. I have tested the change but wish to continue with some more tests. I propose the attached patches for testing.

The original `fix', checking that a free variable is bound in the environment, might still be useful. The compiler is surely lacking in assertions and self checks. Will incorporate the change into my own branches and possibly submit a patch in the future.

buildom.boot.pamphlet.patch

changelog.patch

10 Jul 2007

The original fix had problems. It took the approach of `normalizing' the input so that compWithMappingMode could swallow it. Unfortunately it did not normalize all such expressions. It fixed the defintrf.spad bug, but not the bug in general.

The following change appears to be a general fix. It makes compWithMappingMode lift only the identifiers it can prove are bound. Since record and union fields are not bound identifiers, they are properly ignored.

20070710-compiler.boot.pamphlet.patch

fixed and commited --swilson, 2007年7月14日 15:29:48 -0500 reply
Status: testing => pending (next release)

... --kratt6, 2007年12月28日 15:24:53 -0800 reply
Status: pending (next release) => fix proposed

fixed in FriCAS --kratt6, 2008年1月03日 05:03:41 -0800 reply
see http://groups.google.com/group/fricas-devel/msg/43c2a2bd6e64fc13

... --gdr, 2008年1月21日 16:28:03 -0800 reply
Fixed on OpenAxiom

... --kratt6, 2008年1月26日 11:03:19 -0800 reply
Status: fix proposed => closed




Subject: Be Bold !!
( 15 subscribers )
Please rate this page:

AltStyle によって変換されたページ (->オリジナル) /