Skip to content
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

Function arguments names restriction #6621

Open
1 task done
f0nar opened this issue Jun 4, 2024 · 0 comments
Open
1 task done

Function arguments names restriction #6621

f0nar opened this issue Jun 4, 2024 · 0 comments
Labels
🐛 bug This is a bug impacting users

Comments

@f0nar
Copy link
Contributor

f0nar commented Jun 4, 2024

Is there an existing issue for this?

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 window variable 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

  1. Create custom extension
  2. Add function of expression and condition type
  3. Add to it parameter with "Number" name
  4. Make it return Number
  5. In function eventsheet create js code block and add there
const numberParam = eventsFunctionContext.getArgument("Number");
eventsFunctionContext.returnValue = Math.random() * 100;
  1. Use defined function in scene eventsheet

GDevelop platform

Desktop

GDevelop version

5.3.194

Platform info

No response

Additional context

No response

@D8H D8H added the 🐛 bug This is a bug impacting users label Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug This is a bug impacting users
Projects
None yet
Development

No branches or pull requests

2 participants