[nem-en] Re: conversion of int to uint

Valient Gough valient at gmail.com
Thu Feb 23 07:36:02 CET 2006


Sorry, GMail got confused...  I wasn't ready to send.

Hi,

I'm having trouble converting from an int to uint.  I have to convert
to a common type because I need to apply a bit-field operation, and
I'm constrained on the different types from external interfaces.

My expectation was for something like this to work:

def checkMask( mask, modes )
{
    if((mask :> uint) %& modes)
        0;
    else
        ErrorCode.EACCES;
}

But that gives an error "System.Int32 is not a subtype of
System.UInt32 [simple require]"

So I searched around the nemerle site and didn't see anything. I tried
other variations without success, and then I tried casting the uints
to ints and got an interesting error:  "common super type of types
[System.UInt32, int] is just `System.ValueType', please upcast one of
the types to `System.ValueType' if this is desired
"

So, I tried to force a conversion through ValueType:

def checkMask( mask : ValueType , modes )
{
    if((mask :> uint) %& modes)
...

That resulted in an ICE:
error: internal compiler error: assertion failed in file
generation/ILEmitter.n, line 778:
Sulf.GenericNode::Access: failed to convert non-value type
System.ValueType to a value type System.UInt32


While I realize that an ICE should go in a bug report, I don't really
want to cast to ValueType anyway, all I want to do is cast between an
int and uint.. There must be an easy way that I'm missing.

regards,
Valient



More information about the devel-en mailing list