You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interface CDObject {
}
@:keepSub
@:structInit class CUIObject implements CDObject {
public var name: String = null;
public function clone( )
{
var cls = Type.getClass(this);
var inst = Type.createEmptyInstance(cls);
var fields = Type.getInstanceFields(cls);
for (field in fields)
{
// generic copy
var val:Dynamic = Reflect.field(this,field);
if ( !Reflect.isFunction(val) )
{
Reflect.setField(inst,field,val);
}
}
return inst;
}
}
class Test {
static function main() {
var foo: CUIObject = {};
foo.clone();
trace("OK!");
}
}
This code fails, as the last entry in fields is an empty string (and trying to touch empty string as a field results in an expected error)
This only happens in HL, and only when the object has an interface. If we remove the implements then the code works correctly.
The text was updated successfully, but these errors were encountered:
A try.haxe link: https://try.haxe.org/#38AB9237
And the code for posterity:
This code fails, as the last entry in
fields
is an empty string (and trying to touch empty string as a field results in an expected error)This only happens in HL, and only when the object has an interface. If we remove the
implements
then the code works correctly.The text was updated successfully, but these errors were encountered: