PR# 19493 Type Mismatch with Anchor Argument Not Caught at Compile Time
Problem Report Summary
Submitter: q2santos
Category: Compiler
Priority: Medium
Date: 2018/11/05
Class: Bug
Severity: Serious
Number: 19493
Release: 18.7
Confidential: No
Status: Open
Responsible:
Environment: any
Synopsis: Type Mismatch with Anchor Argument Not Caught at Compile Time
Description
As illustrated by the following example, if there's a type mismatch between the mapper's result and the anchor, it is only caught at runtime as a catcall exception. Instead, it could be a compile-time error, because the actual type of the anchor is already know when the map function is called. On the other hand, a type mismatch on the variable receiving the result of the map function is caught at compile time already, which is the expected behaviour. (See it by replacing anchor's value "" with 0 in the map function's call.)
To Reproduce
note description: "map_testers application root class" date: "$Date$" revision: "$Revision$" class APPLICATION inherit ARGUMENTS_32 create make feature {NONE} -- Initialization make -- Run application. local target: ITERABLE [STRING] do target := map (<<1, 2, 3>>, "", agent identity (?)) across target as cursor loop print (cursor.item + "%N") end end identity (n: INTEGER): INTEGER do Result := n end feature {NONE} -- Mapping map (source: ITERABLE[INTEGER]; anchor: ANY; mapper: FUNCTION[INTEGER, like anchor]): ITERABLE[like anchor] local target: ARRAYED_LIST[like anchor] do create target.make (10) across source as cursor loop target.extend (mapper (cursor.item)) end Result := target end end
Problem Report Interactions