HaxeFoundation / HaxeFoundation/haxe

Confusing error: haxe.extern.EitherType<Float, Point> should be Int

Open
#7,432 1 comment 0 reactions 0 assignees View on GitHub
error-reporting
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

The following piece of code throws compiler error `haxe.extern.EitherType should be Int`.

This is confusing, since there is no `Int` involved in this case. I encountered this in actual project with externs involved, where it first took me a while to know the issue was that extern function could return more than just a float (so that was my problem), but I still didn't found the error helpful. I reduced it to this:

```haxe
class Test {
static function main() {
foo() / 5.0; // haxe.extern.EitherType should be Int
}

static function foo():haxe.extern.EitherType return cast 3.0;
}

class Point {
public function new() {}
}
```

https://try.haxe.org/#15bF6
Haxe 3.4.7

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.