PR# 3710 Inserting an 'expanded B' to a 'TUPLE [expanded B]'

Problem Report Summary
Submitter: gobobe
Category: EiffelBase
Priority: Medium
Date: 2004/03/20
Class: Bug
Severity: Serious
Number: 3710
Release: 5.5.0409
Confidential: No
Status: Open
Responsible:
Environment: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
Synopsis: Inserting an 'expanded B' to a 'TUPLE [expanded B]'

Description
ISE Eiffel 5.5.0409

Following the bug report [Run-time/3709], let's consider again this class:

---------------------
class B

inherit

	ANY
		redefine
			default_create
		end

create

	default_create,
	make_from_expanded

convert
	make_from_expanded ({expanded B}),
	to_expanded: {expanded B}

feature

	default_create is
			-- 
		do
			i := 45
		end

	make_from_expanded (b: expanded B) is
		do
			i := b.i
		end

	to_expanded: expanded B is
		do
			Result.set_i (i)
		end

	i: INTEGER

	set_i (int: INTEGER) is
		do
			i := int
		end

end
---------------------

We saw in the bug report [Run-time/3709] that the item of 'TUPLE [expanded B]' was not initialized as expected when creating the Tuple (it was erroneously set to Void, which is not a valid value for an expanded entity). In order to work around this problem I tried to give this item a valid value:

---------------------
class A

create

	make

feature

	make is
		local
			tb: TUPLE [expanded B]
			b: expanded B
		do
			create tb
			tb.put (b, 1)
		end

end
---------------------

This code compiles fine, but I got the following exception trace when executing it:

-------------------------------------------------------------------------------
Class / Object      Routine                Nature of exception           Effect
-------------------------------------------------------------------------------
TUPLE               put @2                 valid_type_for_index:        
<0000000000B80060>                         Precondition violated.        Fail
-------------------------------------------------------------------------------
A                   make @2                                             
<0000000000B80048>                         Routine failure.              Fail
-------------------------------------------------------------------------------
A                   root's creation                                     
<0000000000B80048>                         Routine failure.              Exit
-------------------------------------------------------------------------------

Indeed, in the call to `put' the expanded entity `b' is converted to its reference form, and 'reference B' does not conform to 'expanded B', it only converts to it.

It seems to me that the problem is in the implementation of `valid_type_for_index' in class TUPLE. Apparently we go into the 'reference_code' branch, even though the item of the Tuple is expanded. And then only conformance is considered, not convertability.
To Reproduce

										
Problem Report Interactions
From:gobobe    Date:2004/03/20    Download