HaxeFoundation / HaxeFoundation/HaxeManual
Semantics of different abstract implict cast kinds are not the same
- Dominant language
- Haxe
- Stars
- 225
- Forks
- 156
- Avg merge
- 5h 16m
- Merged PRs (30d)
- 1
Description
https://haxe.org/manual/types-abstract-implicit-casts.html claims that `to` and `@:to` should be identical in behavior:
>Class field casts have the same semantics, but are defined completely differently:
In practice this doesn't seem to be the case:
```haxe
import haxe.ds.HashMap;
class Main {
static function main() {
var map1 = new HashMap(); // works
var map2 = new HashMap(); // constraint check failure
}
}
abstract Hashable1(HashableImpl) to {function hashCode():Int;} {}
abstract Hashable2(HashableImpl) {
@:to function toHashCode():{function hashCode():Int;} {
return this;
}
}
class HashableImpl {
public function new() {}
public function hashCode():Int {
return 0;
}
}
```
@RealyUniqueName says this is by design, and thus should be documented accordingly. Would be helpful to have a list of situations where `@:to` and `@:from` are not considered.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked implicit-casts manual page and compare its claim about `to` and `@:to` with the provided `Hashable1` and `Hashable2` example. Confirm the differing behavior, then update the documentation to explain the distinction and list situations where `@:to` and `@:from` are not considered equivalent.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100