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 4 of 11

1 2 3 4 5 6 7 8 9 10 11
Editor: gdr
Time: 2008/02/21 22:04:56 GMT-8
Note:

added:

From gdr Thu Feb 21 22:04:56 -0800 2008
From: gdr
Date: Thu, 21 Feb 2008 22:04:56 -0800
Subject: 
Message-ID: <20080221220456-0800@axiom-wiki.newsynthesis.org>

Status: open => fixed somewhere 


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 FriCAS 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.06 SEC.
(time taken in buildFunctor:  0)
;;;     ***       |testtype| REDEFINED
;;;     ***       |testtype| REDEFINED
Time: 0 SEC.
   Cumulative Statistics for Constructor testtype
      Time: 0.06 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 FriCAS 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.
#1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL'
"/var/zope2/var/LatexWiki/7383689924623811223-25px003.as", line 5: 
    tt2(x:Integer):Type == {
........^
[L5 C9] #2 (Warning) Function returns a domain that might not be constant (which may cause problems if it is used in a dependent type).
   Compiling Lisp source code from file 
      ./7383689924623811223-25px003.lsp
   Issuing )library command for 7383689924623811223-25px003
   Reading /var/zope2/var/LatexWiki/7383689924623811223-25px003.asy
   testtype2 is now explicitly exposed in frame initial 
   testtype2 will be automatically loaded when needed from 
      /var/zope2/var/LatexWiki/7383689924623811223-25px003

axiom
tt2(1)
LatexWiki Image(1)
Type: Type
axiom
tt2(0)
LatexWiki Image(2)
Type: Type

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.

Status: open => fixed somewhere