double casted to IMyInterface

0 views
Skip to first unread message

nemerle fanboy

unread,
Oct 23, 2008, 11:16:35 AM10/23/08
to Nemerle Forum

The other day I casted a bool to an interface explicitly. The compiler
was ok.
When I invoked the methods I got a run-time exception (entry point not
found).

Is it a compiler bug?

VladD2

unread,
Oct 23, 2008, 1:53:46 PM10/23/08
to nemer...@googlegroups.com
2008/10/23 nemerle fanboy <nemerle...@yahoo.it>:

> The other day I casted a bool to an interface explicitly. The compiler
> was ok.
> When I invoked the methods I got a run-time exception (entry point not
> found).

Code like:
WriteLine((true : IConvertible).ToInt32(null));
work fine.
What do you mean?

nemerle fanboy

unread,
Oct 26, 2008, 8:42:16 PM10/26/08
to Nemerle Forum
Sorry for the delay. I'm having problems with google groups.

Can I assume true actually implements IConvertible?

double doesn't implement IMyFunnyInterface.
A explicit cast was provided (it returns a wrapper object implementing
that interface) but, probably because it was defined in the wrong
place, it was not called (breakpoint not hit).

The double was converted anyway and passed to a function as argument,
causing said runtime exception.

Is it by design?

On Oct 23, 6:53 pm, VladD2 <v...@rsdn.ru> wrote:
> 2008/10/23 nemerle fanboy <nemerle.is_c...@yahoo.it>:

Dmitry Ivankov

unread,
Oct 27, 2008, 4:29:12 AM10/27/08
to nemer...@googlegroups.com
On Mon, Oct 27, 2008 at 5:42 AM, nemerle fanboy <nemerle...@yahoo.it> wrote:

Sorry for the delay. I'm having problems with google groups.

Can I assume true actually implements IConvertible?

double doesn't implement IMyFunnyInterface.
A explicit cast was provided (it returns a wrapper object implementing
that interface) but, probably because it was defined in the wrong
place, it was not called (breakpoint not hit).

The double was converted anyway and passed to a function as argument,
causing said runtime exception.

Is it by design?
Currently explicit conversions are looked up only in "from" type.
It should be either allowed to define them in other places or give a warning/error if we are trying to define conversion operator with from not equal to (or maybe  +some inheritance stuff) the declaring class.
Generating invalid IL is a bug itself in any case.
Reply all
Reply to author
Forward
0 new messages