The nominal subtyping test is nonsense:
typedef mylong = long;
ctor mylong (x:int) => x.long;
supertype mylong (x:int) => x.mylong;
println$ 12.mylong;
So, this is just saying long is supertype of int, which it already is.
You cannot do this sanely, typedefs are just factored away.
But what I do not understand is that the result is 64.
The C++ code is an infinite loop:
void _init_(FLX_APAR_DECL_ONLY){
{
_a17385t_70713 _tmp70732 = ::flx::rtl::strutil::str<long>(_ctor_mylong(12)) + ::std::string("\n") ;
::flx::rtl::ioutil::write(stdout,((_tmp70732)));
}
fflush(stdout);
…..
//------------------------------
//C FUNC <67823>: _ctor_mylong
long _ctor_mylong( int _vI67825_x){
return (_supertype_mylong(_vI67825_x)) ;
}
//------------------------------
//C FUNC <67826>: _supertype_mylong
long _supertype_mylong( int _vI67828_x){
return _ctor_mylong(_vI67828_x);
}
This should crash but prints the wrong answer instead.
Note I had to change the code. The current rule (which sucks) is that
ctors must be applied explicitly, however a supertype coersion is
applied implicitly. To apply it explicitly you have to use a coercion:
x :>> T
The code is WRONG because the coercion shouldn’t be involved at all.
It’s a plain call to the ctor here!
I have another routine with the same problem. I fixed this before but clobbered the
fix. The problem was related to abstract types and explicit returns. When you give
an explicit return type, the value returned is coerced to it. So for example
fun f (x:int): long => x;
should work because long is a supertype of x. It does work.
—
John Skaller
ska...@internode.on.net