PR# 4045 Assignment attempt should be Void, but eventually causes InvalidCastException in .NET

Problem Report Summary
Submitter: peter_gummer
Category: EiffelStudio
Priority: High
Date: 2005/04/04
Class: Bug
Severity: Serious
Number: 4045
Release: 5.5.1012
Confidential: No
Status: Open
Responsible:
Environment: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040626 Firefox/0.9.1
Synopsis: Assignment attempt should be Void, but eventually causes InvalidCastException in .NET

Description
I've run into an invalid cast exception while running a .NET application
that I'm developing. The bug is demonstrated by the the classes below. These
same classes behave correctly in a classic application.

This looks a bit like a catcall, but it isn't. The actual type of 'p' is
CHILD. The assignment attempt (p ?= a) tries to store a CHILD2 object in p.
In a classic application, p is Void. But in .NET, it merrily sets the CHILD2
object, and when the caller tries to access the wrongly assigned 'p' it
throws an InvalidCastException.
To Reproduce
class APPLICATION
      create make
      feature {NONE} make is
            local
                  b: BUG [CHILD]
                  c: CHILD
            do
                  create b.make (create {CHILD2})
                  c := b.p -- InvalidCastException in .NET
            end
end

class PARENT end

class CHILD inherit PARENT end

class CHILD2 inherit PARENT end

class BUG [reference G -> PARENT]
      create make
      feature {NONE} make (a: PARENT) is
            do p ?= a end -- Should be Void
      feature p: G
end
Problem Report Interactions
From:peter_gummer    Date:2005/04/04    Download   
From: Peter Gummer <pgummer@decisions-made-easy.com.au>
To: bugs@support.eiffel.com
Cc: 
Subject: RE: EiffelStudio/4045 - Assignment attempt should be Void, but ev
	entually causes InvalidCastException in .NET
Date: Tue, 5 Apr 2005 09:13:24 +1000 

 This message is in MIME format. Since your mail reader does not understand
 this format, some or all of this message may not be legible.
 
 ------_=_NextPart_001_01C5396B.E6F0C5B0
 Content-Type: text/plain
 
 Hi,
 
 This error is still happening in 5.6.0721.
 
 - Peter Gummer
 
 
 -----Original Message-----
 From: bugs@berkeley.eiffel.com [mailto:bugs@berkeley.eiffel.com] 
 Sent: Wednesday, 22 September 2004 10:24
 To: pgummer@decisions-made-easy.com.au
 Subject: EiffelStudio/4045
 
 Thank you very much for your problem report.
 It has the internal identification `EiffelStudio/4045'.
 
 If you want to add more information to your report or
 reply to our answer, please reply to this message
 without modifying the subject header.
 
 The individual assigned to look a
....
Output truncated, Click download to get the full message