HaxeFoundation / HaxeFoundation/hxcpp
Typedefs doesn't give hint about the type of the field on runtime.
- Dominant language
- C++
- Stars
- 330
- Forks
- 227
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 18
Description
Code below will do an `Int` multiplication and overflow even though typedef suggests to use the `floatField` field as a type of `Float`.
```haxe
typedef TestDef = {
@:optional var floatField:Float;
}
typedef TestDef2 = {
@:optional var multiplied:Float;
}
class Test {
static function main() {
if (testOverflow()) trace("testOverflow passed");
else trace("testOverflow failed");
}
static function testOverflow():Bool {
trace("starting testOverflow");
var testDef:TestDef = { floatField: 50000000 };
var def:TestDef2 = {
multiplied: testDef.floatField * 400
};
trace('result is: ${def.multiplied}');
return def.multiplied > 0;
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.