Mantis

View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006351Runner[All Projects] FunctionsPublic2012-08-31 14:542017-08-03 11:10
Reportercsanyk 
Assigned ToMike Dailly 
PriorityLowSeverityC - GeneralReproducibility100%
StatusClosedResolutionWon't Fix 
PlatformWindows, HTML5OSWindows 7 x64 ProfessionalOS Version7
Summary0006351: string concatenation with non-string values is inconsistent across platforms
DescriptionI've only been able to test this on HTML5 and Windows, but if I do something like the following:

number = 7;
my_string = "This part is a string" + number;

It works if I build an HTML5 game. It throws an error at runtime if I build to Windows.

The fix for windows of course is to use the string() function to cast the number variable to a string:

my_string = "This part is a string" + string(number);

And of course since the HTML5 runner is Javascript, casting number values to a string data type is not necessary on HTML5, which explains why it works without explicit casting on that platform.

The reason I consider this a bug is that the code should compile and execute as close to identically as possible regardless of build target.

In my opinion, the ideal fix for this would be for the Windows runner to automatically cast numeric values to string when the + operator is used in a statement where one of the arguments is a string. This would make the identical running code work on Windows or HTML5.

I have not been able to test the behavior on any other platforms.
Steps To Reproducewrite a GML statement that adds a number to a string. Build to Windows and run, it errors at run time. Build to HTML5 and it works.
1.4 Version1.1.xxx
2.x Runtime Version
2.x Runtime Version Verified In2.1.0.124
Attached Files? file icon StringConcatenation.gmz [^] (903,902 bytes) 2014-06-16 16:35

- Relationships

-  Notes
(0029785)
Neil Wicker (Updater)
2014-06-16 16:35

This still occurs in 1.3.1354

Interestingly, the program runs on Windows YYC but the string is not concatenated. Which means the behavior on Windows, Windows YYC and HTML5 are all different. I've uploaded a sample program which allows the problem to be seen.
(0053195)
Mike Dailly (Manager)
2017-05-18 08:52

Because we compile to "native" JavaScript there will always be language specific issues, from things like this to argument stacking (i.e. call(a++,a++,a++) ) that may differ.

The only way to change this to make things consistent with Native (and not the other way around) is to add checking code above which would slow everything down.

Since everyone (pretty much) uses the Native version, that is considered the correct version, and if it works there should work in HTML5 - language issues aside.

So this is not something we'll look to "fix" as it would hit HTML5 performance.


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker