Function arguments names restriction
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
I found funny issue I am sure it is not super priority task but I think it is useful to know
The key is that we cannot use any name as parameters for expression and condition functions (possibly action too, I didnt check it yet)
I created function of expression and condition type with parameter named "Number" and return type "Number". Once I used it I receive error that Number is not function.
The key is that after gdevelop function transpilation we receive js function with parameters named as ones in gdevelop. So we will have parameter Number of number type and later you are trying to use global Number function to process returned value. Here is the issue)
I think it is might be super unobvious for guys who didnt have coding experience.
I see three solutions:
- Change parameters naming during transpilation. E.g. Number -> Number / #Number / par_Number and so on or wrap them with object and pass like { Number } (later usage param.Number)
- Somehow wrap all global enteties usage. Use it through
windowvariable or wrap with object and pass like context - Make list of reserved names and disallow user to use them with UI warning
Steps to reproduce
- Create custom extension
- Add function of expression and condition type
- Add to it parameter with "Number" name
- Make it return Number
- In function eventsheet create js code block and add there
const numberParam = eventsFunctionContext.getArgument("Number");
eventsFunctionContext.returnValue = Math.random() * 100;
- Use defined function in scene eventsheet
GDevelop platform
Desktop
GDevelop version
5.3.194
Platform info
No response
Additional context
No response