HaxeFoundation / HaxeFoundation/haxe
Uncomparable abstract
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
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.
```haxe
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 !
}
}
```
Contributor guide
Research direction
Start by reproducing the Haxe example and comparing the existing enum diagnostic with abstract equality behavior. Then trace the compiler’s handling of abstract metadata and equality checks; done means an abstract tagged with `@:uncomparable` rejects `==` and `!=` comparisons with a comparable error.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100