HaxeFoundation / HaxeFoundation/haxe
to Float on abstract is getting ignored, can't do math operations
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
```hx
class Test {
static function main() {
var now = Date.now().getTime() - Foo.a;
trace(now);
}
}
enum abstract Foo(Float) to Float {
var a = 10000001;
}
```
This results in the following error:
```
[ERROR] Test.hx:3: characters 38-43
3 | var now = Date.now().getTime() - Foo.a;
| ^^^^^
| Foo should be Int
```
But everything here is typed and declared as `Float` so why is it that I can't do the subtraction?
Contributor guide
Research direction
Compile the Test.hx reproduction first and confirm the reported “Foo should be Int” diagnostic. Then trace how enum abstract Foo(Float) to Float is handled during subtraction and type checking; done means the example compiles and the subtraction works as intended, with a regression test following the project’s existing test layout.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 32/100