HaxeFoundation / HaxeFoundation/hxcpp
hxcpp 3.2 regression: re-assignment of a dynamic variable to a different type fails
- Dominant language
- C++
- Stars
- 330
- Forks
- 227
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 18
Description
Here is a sample code:
```
class Foo
{
public static function main()
{
var json = haxe.Json.parse("{\"array\":[\"Hello\"]}");
var field = Reflect.field(json, "array");
if (field == null) {
throw("Reflect failed!");
}
if (Std.is(field, Array)) {
var array : Array = field;
if (0 < array.length) {
trace("Assigning field from [" + field +
"] to [" + array[0] + "]");
field = array[0];
}
}
trace("field is " + field);
}
}
```
The variable 'field' is re-used both as an Array, and as a value within the Array. But since the type of 'field' is Dynamic (as inferred by the return type of Reflect.field()), assigning it to any value subsequently should work.
Expected result:
Foo.hx:17: Assigning field from [[Hello]] to [Hello]
Foo.hx:23: field is Hello
Actual results:
- haxe 3.1.3, neko target: as expected
- haxe 3.1.3, hxcpp target: as expected
- haxe 3.2, neko target: as expected
- haxe 3.2, hxcpp target: invalid result:
Foo.hx:17: Assigning field from [[Hello]] to [Hello]
Foo.hx:23: field is null
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.