HaxeFoundation / HaxeFoundation/haxe
False-positive unification error in a specific mix of constrained type params + inlined calls
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
```haxe
class Main {
public static function main() {
flatMap(new Collection(), function(i) return [i]);
}
public static inline function map>(it:T, f:A->B):Array {
return [for (x in it) f(x)];
}
public static inline function flatten, L:Iterable>(it:L):Array {
return [for (e in it) for (x in e) x];
}
public static inline function flatMap(it:Iterable, f:A->Iterable):Array {
return flatten(map(it, f));
}
}
class Collection {
public inline function new() {}
public inline function iterator() return new CollectionIterator();
}
class CollectionIterator {
public inline function new() {};
public inline function hasNext() return false;
public inline function next() return (null:V);
}
```
```
$ haxe -main Main -js test.js
Main.hx:15: characters 12-31 : error: flatMap.B should be Int
Main.hx:15: characters 12-31 : have: (...) -> { next: (...) -> { iterator: (...) -> { next: (...) -> flatMap.B } } }
Main.hx:15: characters 12-31 : want: (...) -> { next: (...) -> { iterator: (...) -> { next: (...) -> Int } } }
```
Broken since 4.0.0-preview.4
Contributor guide
Assessment
This issue has not been assessed yet.