Closed kevinresol closed 8 years ago
The main function gets compiled to the code snippet below. I think the type might get lost because of the continuation of the default case. Is this causing you serious problems? Because I'm unsure if I can get this fixed. Typing it as var value: Int = switch ...
will help.
string().handle(function(__t2) {
var __t2_result;
switch tink.await.OutcomeTools.getOutcome(__t2) {
case Success(v):{
__t2_result = v;
};
case Failure(e):{
throw e;
return;
};
};
{
function __t0(__t1) {
var value = __t1;
$type(value);
};
switch __t2_result {
case 's':int().handle(function(__t3) {
var __t3_result;
switch tink.await.OutcomeTools.getOutcome(__t3) {
case Success(v):{
__t3_result = v;
};
case Failure(e):{
throw e;
return;
};
};
{
var i = __t3_result;
$type(i);
__t0(i);
};
});
default:__t0({
throw 'error';
});
};
};
})
This is not a big problem for me, I can just type hint it explicitly.
It is actually not caused by the default case, but by the fact that the function __t0
is not type-hinted. It can be demonstrated in the following example.
class Main {
static function main() {
function t(v) {
$type(v); // Unknown
}
t('str');
t(throw 0);
}
}
$type(i)
givesInt
correctly, but when it is assigned tovalue
,$type(value)
becomesUnknown
.