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
@:using(Test.MyEnumUtils)
enumA {
VA;
VB(isX:Bool);
}
abstractB(A) fromA {
@:tofunctiontoString() returnthis.toString();
}
classMyEnumUtils {
publicstaticfunctiontoString(v:A) returnswitchv {
caseVA: "this is va";
caseVB(false): "this is vb false";
caseVB(true): "this is vb true";
};
}
classTest {
staticfunctionmain() {
varm=VB(true);
trace(m);// toString is not calledtrace('$m');// toString is not calledtrace(m.toString());// toString is called ... obviouslyvarm:B=m;
trace(m);// toString is calledtrace('$m');// toString is called
}
}
In the trace('$m') case the compiler explicitly inserts a Std.string and to expect the toString to be used there if available seems quite reasonable. In the trace(m) case I'm not so sure what the behavior should be, but FWIW I think the best option would be to make it work the same as it works for abstracts.
The text was updated successfully, but these errors were encountered:
Hmm, I thought trace(m) wasn't very strictly defined because we might want to utilize native tracing capabilities in that case. Abstracts seem a bit special in that regard because they have no run-time representation by their very nature, so toStringing them is fair enough. For normal types one could argue that String isn't involved at all.
AFAF: https://try.haxe.org/#52ff1319
In the
trace('$m')
case the compiler explicitly inserts aStd.string
and to expect thetoString
to be used there if available seems quite reasonable. In thetrace(m)
case I'm not so sure what the behavior should be, but FWIW I think the best option would be to make it work the same as it works for abstracts.The text was updated successfully, but these errors were encountered: