PR# 18452 "like" types; compiler accepts invalid code
Problem Report Summary
Submitter: soapy2357
Category: Compiler
Priority: Medium
Date: 2012/12/14
Class: Bug
Severity: Serious
Number: 18452
Release: 7.1.8.8986
Confidential: No
Status: Analyzed
Responsible:
Environment: has no influcence
Synopsis: "like" types; compiler accepts invalid code
Description
Creates a runtime segfault (I expected the compiler to reject it): make do Io.put_string (iif (True, "1", 2) + "%N") Io.put_string (iif (False, "1", 2) + "%N") end iif (a_condition: BOOLEAN; a_then, a_else: ANY): like a_then -- return a_condition ? a_then : a_else; do if a_condition then Result := a_then else Result := a_else end end I was just curious about how the compiler will react (I have very bad experiences with "like" types). I actually use: iif (a_condition: BOOLEAN; a_then: ANY; a_else: like a_then): like a_then -- return a_condition ? a_then : a_else; do if a_condition then Result := a_then else Result := a_else end end
To Reproduce
Problem Report Interactions
Anchored types that use arguments as anchors are not part of Eiffel standard. They are not rejected by EiffelStudio for backward compatibility, but their complete support is not planned either, because there is no specification that can be used to implement them.