PR# 19425 function returning an anchored type is returning incorrect type in finalized executable

Problem Report Summary
Submitter: finnianr
Category: Compiler
Priority: High
Date: 2018/01/23
Class: Bug
Severity: Serious
Number: 19425
Release: 16.05
Confidential: No
Status: Open
Responsible:
Environment: linux
Synopsis: function returning an anchored type is returning incorrect type in finalized executable

Description
I have defined a function `new_meta_data' in class `EL_REFLECTIVE' which returns a type anchored to the type of `Meta_data_by_type.item' as shown in the following code fragment.
(The purpose of EL_FUNCTION_RESULT_TABLE is explained in this forum post https://groups.google.com/forum/#!topic/eiffel-users/bEQGkTU9G8U)

deferred class
	EL_REFLECTIVE

feature {EL_REFLECTIVE} -- Factory

	new_meta_data: like Meta_data_by_type.item
		do
			create Result.make (Current)
		end

feature {NONE} -- Once per type tables

	Meta_data_by_type: EL_FUNCTION_RESULT_TABLE [EL_REFLECTIVE, EL_CLASS_META_DATA]
		once
			create Result.make (11, agent {EL_REFLECTIVE}.new_meta_data)
		end
end

The problem I have is with a redefinition of `Meta_data_by_type' in a class `EL_REFLECTIVELY_SETTABLE_STORABLE' as show in this code fragment:
(EL_REFLECTIVELY_SETTABLE inherits EL_REFLECTIVE)

deferred class
	EL_REFLECTIVELY_SETTABLE_STORABLE

inherit
	EL_REFLECTIVELY_SETTABLE
		rename
			field_included as is_storable_field
		export
			{EL_MEMORY_READER_WRITER} make_default, generating_type
		redefine
			is_equal, use_default_values, Except_fields, Meta_data_by_type
		end

	EL_STORABLE
		undefine
			is_equal, print_meta_data
		end

feature {NONE} -- Constants

	Meta_data_by_type: EL_FUNCTION_RESULT_TABLE [EL_REFLECTIVELY_SETTABLE_STORABLE, EL_STORABLE_CLASS_META_DATA]
		once
			create Result.make (11, agent {EL_REFLECTIVELY_SETTABLE_STORABLE}.new_meta_data)
		end
end

In workbench mode `new_meta_data' works correctly and returns a result of type EL_STORABLE_CLASS_META_DATA, however in the finalized exe this function is still returning the ancestor type EL_CLASS_META_DATA. Obviously this is a bug in the compiler which is generating incorrect C code.

As a workaround I have redefined `new_meta_data' in class EL_REFLECTIVELY_SETTABLE_STORABLE using precisely the same code as the ancestor.

I have attached the relevant source in case it is of use.
To Reproduce

										
Problem Report Interactions
From:finnianr    Date:2018/01/23    Status: Open    Download   
Further to the workaround for this bug I decided to see if could abolish the redefinition of `Meta_data_by_type'  in class EL_REFLECTIVELY_SETTABLE_STORABLE and instead define the return types of `new_meta_data' explicitly as EL_CLASS_META_DATA and EL_STORABLE_CLASS_META_DATA for class EL_REFLECTIVELY_SETTABLE_STORABLE. This seems to have worked so this bug has a silver lining :-) My code is now simplified.

From:finnianr    Date:2018/01/23    Status: Open    Download   
NB The redefinition of `new_meta_data' in class EL_REFLECTIVELY_SETTABLE_STORABLE is a workaround for the bug and should not be necessary if the anchored type is working correctly.

From:finnianr    Date:2018/01/23    Download   
Attachments for problem report #19425

Attachment: el_function_result_table.e     Size:1470
Attachment: el_reflective.e     Size:7603
Attachment: el_reflectively_settable_storable.e     Size:5617