waneck / haxe-genc

20 stars 2 forks source link

structs cast #16

Closed waneck closed 11 years ago

waneck commented 11 years ago

While struct unboxing should be allowed, casting from a struct into another should be an error when both aren't the same type

Simn commented 11 years ago

In which cases does that happen? The haxe compiler does not allow structural subtyping between two structs.

waneck commented 11 years ago

Some untyped / unsafe cast call may generate this. I'd rather have haxe throwing a nice error than delegating it to the C compiler

Simn commented 11 years ago

In untyped mode you could cast a struct to anything, even an Int. So I don't quite understand why we should treat the struct vs. struct case in a special way.

waneck commented 11 years ago

Hmm that's true. We may run into issues when dealing with e.g. @:generic, which is known to generate code that is a little annoying to handle... Well, it doesn't hurt to check and send an error message

Simn commented 11 years ago

I don't really see the point of allocating any effort to that just to give "This expression probably doesn't compile through C"-style errors. If something like that originates from typed code, we should check why that happens. If it comes from using untyped then it's the user's own problem IMHO.