Subject: fixbug
By: MND
Fixed: bug1172.as
--* From Manuel.Bronstein@sophia.inria.fr  Fri Oct  8 13:34:22 1999
--* Received: from droopix.inria.fr (IDENT:root@droopix.inria.fr [138.96.111.4])
--* 	by nagmx1.nag.co.uk (8.9.3/8.9.3) with ESMTP id NAA07299
--* 	for <ax-bugs@nag.co.uk>; Fri, 8 Oct 1999 13:34:07 +0100 (BST)
--* Received: by droopix.inria.fr (8.8.8/8.8.5) id OAA13346 for ax-bugs@nag.co.uk; Fri, 8 Oct 1999 14:29:53 +0200
--* Date: Fri, 8 Oct 1999 14:29:53 +0200
--* From: Manuel Bronstein <Manuel.Bronstein@sophia.inria.fr>
--* Message-Id: <199910081229.OAA13346@droopix.inria.fr>
--* To: ax-bugs@nag.co.uk
--* Subject: [1] conditional code badly broken

--@ Bug Number:  bug1172.as 
--@ Fixed  by:  MND   
--@ Tested by:  bug1172.as 
--@ Summary:    gen0DefDefTypeCond tracks if-conds and gen0Define juggles with them 

-- Command line: none
-- Version: 1.1.12p2
-- Original bug file name: condcode.as

----------------------------- condcode.as ----------------------------------
--
-- This compiles silently but produces bad code!
-- The Ring version of foo overwrites the other one in addLevel1
-- causing a runtime error:
--
-- % axiomxl -q1 -ginterp condcode.as
-- Looking in String for + with code 569058384
-- Export not found
--
-- Maybe related to bugs 969 and 1170
--
-- The only workaround is to test 'T has Ring' in *every* call to
-- foo, which is not really efficient.
--

#include "axllib"

Foo(T:Type): with { foo: T -> T } == add {
	if T has Ring then {
		foo(a:T):T == a + a;
	}
	else {
		foo(a:T):T == a;
	}
}

import from String, Foo String;
foo "very bad bug"

