-
-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic vs. String #9586
Dynamic vs. String #9586
Conversation
Do you really want to specify that any value in any runtime can be converted to a string? |
We already specify that this works in the context of string concatenation. |
But we do that by inserting |
My main point is that I think these two traces should behave the same way: function getDynamic():Dynamic {
return 12;
}
function main() {
trace("Value: " + getDynamic());
var value = getDynamic();
trace("Value: " + value);
} Ultimately this is an issue with |
I think current behavior is correct. It's specified that monomorph is not bound to |
Otherwise we'll have to do something with all the similar cases. E.g. #9524 |
What do you mean "everywhere"? This is specifically about assigning |
I mean in general it's impossible to detect if a value came from function print(s:String) {
trace('Message: ' + s);
}
var v = getDynamic();
print(v); have to be generated as function print(s:String) {
trace('Message: ' + Std.string(s)); //Std.string on every concatenation
}
var v = getDynamic();
print(v); |
The conversion would be done void Main_Fields__obj::main(){
HX_STACKFRAME(&_hx_pos_195033e4c87195a0_9_main)
HXLINE( 10) ::String v = ( (::String)(::_Main::Main_Fields__obj::getDynamic()) );
HXLINE( 11) ::_Main::Main_Fields__obj::print(v);
} And Java: public static void main()
{
//line 10 "C:\\git\\haxerepro\\source\\Main.hx"
java.lang.String v = haxe.lang.Runtime.toString(_Main.Main_Fields_.getDynamic());
//line 11 "C:\\git\\haxerepro\\source\\Main.hx"
_Main.Main_Fields_.print(v);
} And C#: public static void main() {
#line 10 "C:\\git\\haxerepro\\source\\Main.hx"
string v = global::haxe.lang.Runtime.toString(global::_Main.Main_Fields_.getDynamic());
global::_Main.Main_Fields_.print(v);
} And I guess Flash too because it passes these tests. |
That's better. But it still feels wrong. Quote from the manual:
And yet we try to fix those problems. |
Ironically, part of the problem in #9585 is that he doesn't use |
Why don't we generate |
For #9585. Currently fails on HL, PHP and python.