PR# 19350 Assigning a tuple attribute with value of correctly conforming type results in a catcall error
Problem Report Summary
Submitter: finnianr
Category: Compiler
Priority: Medium
Date: 2017/04/18
Class: Bug
Severity: Non-critical
Number: 19350
Release: 16.05.9.8969
Confidential: No
Status: Open
Responsible:
Environment: linux
Synopsis: Assigning a tuple attribute with value of correctly conforming type results in a catcall error
Description
The code in routine `assign_tuple_string_1' is perfectly legitimate but fails on the second line in the debugger with a catcall error "Catcall detected for argument#1: expected STRING_8 but got STRING_32". This is clearly wrong since the `tuple.str' has been defined as type READABLE_STRING_GENERAL. The routine `assign_tuple_string_2' executes without any problems. assign_tuple_string_1 local tuple: TUPLE [str: READABLE_STRING_GENERAL] do tuple := ["a"] tuple.str := {STRING_32}"b" end assign_tuple_string_2 local tuple: TUPLE [str: READABLE_STRING_GENERAL] do tuple := [{STRING_32} "a"] tuple.str := {STRING_32}"b" end
To Reproduce
Problem Report Interactions
I think that this is the expected behavior, and you would probably get the same error with an other Eiffel compiler such as Gobo. Taken by itself, the type of: ["a"] is TUPLE [STRING_8]. You can assign it to a variable of static type: TUPLE [str: READABLE_STRING_GENERAL]. But the dynamic type of the object is still TUPLE [STRING_8]. Hence the CAT-call when you try to insert a STRING_32 in this tuple object. You would get exactly the same error if you had written: class A feature str: READABLE_STRING_GENERAL assign set_str set_str (s: like str) do str := s end end class B inherit A redefine str end feature str: STRING_8 assign set_str end and then: local a: A do a := create {B} a.str := {STRING_32}"b" despite the fact that `str' is declared of type READABLE_STRING_GENERAL in class A. -- Eric Bezault