GDevelop
GDevelop copied to clipboard
Debugger not showing variables with a specific "reserved" name
Describe the bug
While I was trying to use an object variable "owner" I perceived it does not get values assigned as expected. This thread covers the events in this respect: https://forum.gdevelop-app.com/t/how-do-i-work-with-string-values-in-object-variable/24941
Only when I renamed the variable to "shotby" the game acted normally. My conclusion is that there are some reserved words that should not be used as variables. Be it a bug that can be removed or a necessity that should be documented, I believe something should be done about this pitfall.
To Reproduce
I attach an almost empty game. It just contains one scene with one object containing three variables. Run this game in the debugger and have a look at the instance. The variable 'owner' shows the value 'undefined' although 'onethousand' is expected.
Other details
This happened on GDevelop 5.0.0.beta93 on Ubuntu 18 amd64
As Github does not allow to upload text files I am listing game.json here:
{
"firstLayout": "",
"gdVersion": {
"build": 98,
"major": 4,
"minor": 0,
"revision": 0
},
"properties": {
"adMobAppId": "",
"adaptGameResolutionAtRuntime": true,
"folderProject": false,
"linuxExecutableFilename": "",
"macExecutableFilename": "",
"orientation": "landscape",
"packageName": "com.example.gamename",
"projectFile": "/home/hiran/Documents/GDevelop projects/My project2/game.json",
"scaleMode": "linear",
"sizeOnStartupMode": "adaptWidth",
"useExternalSourceFiles": false,
"version": "1.0.0",
"winExecutableFilename": "",
"winExecutableIconFile": "",
"name": "Project",
"author": "",
"windowWidth": 800,
"windowHeight": 600,
"latestCompilationDirectory": "",
"maxFPS": 60,
"minFPS": 20,
"verticalSync": false,
"platformSpecificAssets": {},
"loadingScreen": {
"showGDevelopSplash": true
},
"extensions": [
{
"name": "BuiltinObject"
},
{
"name": "BuiltinAudio"
},
{
"name": "BuiltinVariables"
},
{
"name": "BuiltinTime"
},
{
"name": "BuiltinMouse"
},
{
"name": "BuiltinKeyboard"
},
{
"name": "BuiltinJoystick"
},
{
"name": "BuiltinCamera"
},
{
"name": "BuiltinWindow"
},
{
"name": "BuiltinFile"
},
{
"name": "BuiltinNetwork"
},
{
"name": "BuiltinScene"
},
{
"name": "BuiltinAdvanced"
},
{
"name": "Sprite"
},
{
"name": "BuiltinCommonInstructions"
},
{
"name": "BuiltinCommonConversions"
},
{
"name": "BuiltinStringInstructions"
},
{
"name": "BuiltinMathematicalTools"
},
{
"name": "BuiltinExternalLayouts"
}
],
"platforms": [
{
"name": "GDevelop JS platform"
}
],
"currentPlatform": "GDevelop JS platform"
},
"resources": {
"resources": [],
"resourceFolders": []
},
"objects": [],
"objectsGroups": [],
"variables": [],
"layouts": [
{
"b": 209,
"disableInputWhenNotFocused": true,
"mangledName": "New_32scene",
"name": "New scene",
"oglFOV": 90,
"oglZFar": 500,
"oglZNear": 1,
"r": 209,
"standardSortMethod": true,
"stopSoundsOnStartup": true,
"title": "",
"v": 209,
"uiSettings": {
"grid": false,
"gridB": 255,
"gridG": 180,
"gridHeight": 32,
"gridOffsetX": 0,
"gridOffsetY": 0,
"gridR": 158,
"gridWidth": 32,
"snap": true,
"windowMask": false,
"zoomFactor": 1
},
"objectsGroups": [],
"variables": [],
"instances": [
{
"angle": 0,
"customSize": false,
"height": 0,
"layer": "",
"locked": false,
"name": "NewObject",
"width": 0,
"x": 402,
"y": 247,
"zOrder": 1,
"numberProperties": [],
"stringProperties": [],
"initialVariables": []
}
],
"objects": [
{
"name": "NewObject",
"tags": "",
"type": "Sprite",
"updateIfNotVisible": false,
"variables": [
{
"name": "numberVar",
"value": "42"
},
{
"name": "stringVar",
"value": "fourtytwo"
},
{
"name": "owner",
"value": "onethousand"
}
],
"behaviors": [],
"animations": []
}
],
"events": [],
"layers": [
{
"name": "",
"visibility": true,
"cameras": [
{
"defaultSize": true,
"defaultViewport": true,
"height": 0,
"viewportBottom": 1,
"viewportLeft": 0,
"viewportRight": 1,
"viewportTop": 0,
"width": 0
}
],
"effects": []
}
],
"behaviorsSharedData": []
}
],
"externalEvents": [],
"eventsFunctionsExtensions": [],
"externalLayouts": [],
"externalSourceFiles": []
}
I think it's a limitation of the debugger that removes "owner" thinking that this is a reserved name - but the variable should be working properly in the game itself (there should be not reserved name at all in the container holding variables in memory - any name can be used).
Your analysis coudl very well be true. I trusted the debuggerr and assumed the variable would contain a wrong value. After all I also accessed it with the wrong methods.
There is no logging or other output method for variables - thus I believe a correctly working debugger is absolutely required. However it is acceptable to mark some words as reserved so developers do not run into the same issue.
Issue confirmed on my side, undefined pops up when owner is used, even with global variables. Variable content works fine, as suggested by @4ian.
beta 93 installed on Windows10 64-bit.
Confirmed that this is still an issue in v5.0.140:
I wonder what (if any) other variable names do this...?
Ah ha! It appears to be this list of 'excluded keys' that cause problems: https://github.com/4ian/GDevelop/blob/e22611625ed2010725f9131cf74e2e022c74669e/GDJS/Runtime/debugger-client/abstract-debugger-client.ts#L315
Examples:
- _debuggerClient
- linkedObjectsManager
- HSHG
- owner
- baseTexture
- etc.
Granted, most of them aren't likely to be used as variable names. But still...