login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for #206 Interpreter code generation failed for function returning a Type revision 5 of 11

1 2 3 4 5 6 7 8 9 10 11
Editor: Bill Page
Time: 2008/02/25 07:18:02 GMT-8
Note: example

added:

\begin{axiom}
tt:INT->Domain
tt(x)== (x=0 => Integer; Float)
tt(1)
\end{axiom}

Submitted by : (unknown) at: 2007-11-17T22:08:25-08:00 (16 years ago)
Name :
Axiom Version :
Category : Severity : Status :
Optional subject :  
Optional comment :

This function should return a type that depends on a parameter:

axiom
tt:INT->Type
Type: Void
axiom
tt(x)== (x=0 => Integer; Float)
Type: Void
axiom
tt(1) Internal Error Interpreter code generation failed for expression (IF (= |#1| 0) |Integer| |Float|)

Here is the same function in SPAD:

spad
)abbrev package TT testtype testtype(): exports == implementation where exports == with tt1: (Integer) -> Type implementation == add tt1(x) == x=0 => Integer Float
spad
   Compiling OpenAxiom source code from file 
      /var/zope2/var/LatexWiki/8965653050310018446-25px002.spad using 
      old system compiler.
   TT abbreviates package testtype 
------------------------------------------------------------------------
   initializing NRLIB TT for testtype 
   compiling into NRLIB TT 
   compiling exported tt1 : Integer -> Type
Time: 0.05 SEC.
(time taken in buildFunctor:  0)
;;;     ***       |testtype| REDEFINED
;;;     ***       |testtype| REDEFINED
Time: 0 SEC.
   Cumulative Statistics for Constructor testtype
      Time: 0.05 seconds
   finalizing NRLIB TT 
   Processing testtype for Browser database:
--->-->testtype((tt1 ((Type) (Integer)))): Not documented!!!!
--->-->testtype(constructor): Not documented!!!!
--->-->testtype(): Missing Description
------------------------------------------------------------------------
   testtype is now explicitly exposed in frame initial 
   testtype will be automatically loaded when needed from 
      /var/zope2/var/LatexWiki/TT.NRLIB/code

Calling this function like this:

  \begin{axiom}
  tt1(1)
  \end{axiom}

causes Axiom to crash:

  (1) -> tt1(1)

   >> System error:
   Caught fatal error [memory may be damaged]

But this works using Aldor! :-)

aldor
#include "axiom.as"; testtype2(): with { tt2: (Integer) -> Type; } == add { tt2(x:Integer):Type == { x=0 => Integer; Float; } }
aldor
   Compiling OpenAxiom source code from file 
      /var/zope2/var/LatexWiki/7383689924623811223-25px003.as using 
      AXIOM-XL compiler and options 
-O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra
      Use the system command )set compiler args to change these 
      options.
   >> System error:
   GETENV is invalid as a function.

axiom
tt2(1) There are no library operations named tt2 Use HyperDoc Browse or issue )what op tt2 to learn if there is any operation containing " tt2 " in its name. Cannot find a definition or applicable library operation named tt2 with argument type(s) PositiveInteger Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need. tt2(0) There are no library operations named tt2 Use HyperDoc Browse or issue )what op tt2 to learn if there is any operation containing " tt2 " in its name. Cannot find a definition or applicable library operation named tt2 with argument type(s) NonNegativeInteger Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.

The problem here, I believe, is that Type is a category almost isolated. The interpreter thinks of Integer and Float as of type Domain, not Type. If you change the return type from `Type' to `Domain'. It would not work in OpenAxiom?. Both `Type' and `Object' seems to be isolated in the type hierarchy.

Fixed in OpenAxiom? --gdr, Tue, 19 Feb 2008 23:46:28 -0800 reply
This issue is fixed in OpenAxiom?-1.2.0. Comment from me on Friday January 25, 2008 had a typo in it: I meant If you change the return type from `Type' to `Domain'. It would work in OpenAxiom?. Now, the original testcase just works fine.

axiom
tt:INT->Domain Compiled code for tt has been cleared.
Type: Void
axiom
tt(x)== (x=0 => Integer; Float) 1 old definition(s) deleted for function or rule tt
Type: Void
axiom
tt(1)
axiom
Compiling function tt with type Integer -> Domain
LatexWiki Image(1)
Type: Domain

Status: open => fixed somewhere