HaxeFoundation / HaxeFoundation/haxe

abstract @:to order issue

Open
#8,389 1 comment 0 reactions 0 assignees View on GitHub
documentation
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
abstract Abstract(Dynamic) {
@:from public static inline function fromObject(v:Dynamic) { return cast v; }
@:to public inline function toInt():Int return cast this;
@:to public inline function toFloat():Float return this;
}
```
Main.hx
```haxe
var a:Abstract = 0;
var f:Float = a; // [cpp] Float f = ( (Float)(( (int)(a) )) );
var i:Int = a; // [cpp] int i = ( (int)(a) );
```

After reversing order of toInt and to toFloat implicit casts:

```haxe
var a:Abstract = 0;
var f:Float = a; // [cpp] Float f = ( (Float)(a) );
var i:Int = a; // [cpp] int i = ( (int)(a) );
```

Is there any documentation about priority of implicit casts? I found for array access on abstracts to be top to bottom, while for implicit casts seems to be reversed.

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.