Closed
Description
abstract X(Int) from Int to Int {}
class Main {
public static function foo(x:X) {}
public static function main () {
foo(1);
// it seems that the argument becomes TCast(1, None)
// in the typed ast, but it has the type Int instead of X.
// which means generators cannot access the real type of the
// cast expression (in this case X). It could also have other side effects.
}
}
excerpt IRC:
[14:17] <Simn> Hmm, I don't want to add that to the core compiler at the moment.
[14:18] <Simn> Can we do this in check_unification?
[14:18] <frabbit> you mean the cast problem?
[14:19] <frabbit> is loosing the real type a bug in that case? is it inline related?
[14:19] <Simn> Yes
[14:20] <Simn> I don't see why you're saying it loses the real type...
[14:20] <Simn> The real type is Dict, no?
[14:20] <frabbit> yes, but the type of the argument is KwArgs
[14:21] <frabbit> because the functions expects KwArgs
[14:21] <Simn> But then the real expression type is still Dict.
[14:21] <frabbit> and the compiler wraps a cast around it which should have the type KwArgs
[14:22] <frabbit> but i guess it still have the type Dict
[14:23] <frabbit> but i can work around that and use check_unification when the expected type is KwArgs
[14:24] <frabbit> i'm pretty sure that i had a related bug sometime ago in combination with inline
[14:28] <Simn> I don't know if I want to add something like this to the core compiler in a patch release...
[14:29] <Simn> Couldn't we dodge the issue by using @:from and @:to in KwArgs instead?
[14:31] <frabbit> yes, i already done that here, it works fine this way
[14:31] <Simn> You can open an issue for the general case, I'll check it for 3.2.
[14:31] <Simn> It's a bit too intrusive right now.
[14:31] <Simn> Although I'll admit that it does make sense that way.
Activity