haxe
haxe copied to clipboard
Uncomparable abstract
In the following example, we can compare abstracts physically while we would like to avoid that. I propose that we all some abstract to be tagged with metadata @:uncomparable so comparing them with == or != will trigger a similar error as we have with enums.
enum E {
A;
B( x : Int );
}
abstract Abs(E) {
public inline function new(v:E) this = v;
}
class Test {
static function main() {
var a = A;
var b = B(0);
trace( a == b ); // error, which is fine
var a = new Abs(a);
var b = new Abs(b);
trace(a == b); // false !
}
}