The point accessor does not allow you to access undeclared variables anymore (5.6.281)

Describe the bug

In gdevelop 5.6.281, Undeclared children variables are marked as errors in the editor (they were not marked as errors in the previous version of the engine)

Steps to reproduce

  1. Create a structure variable with one child declared (example, foo with child bar).
  2. Modify the declared child variable using the point as an accessor. The editor does not mark it as an error.
  3. Modify an undeclared child variable, once again, using the point accessor. The editor will not allow it.
  4. Modify the same undeclared child variable, this time using square brackets as the accessor. This works.

image

The thing that makes it weirder, is that when you go into the action or conditions pop-up, it does not mark it as an error.

Only when you are in the main page of the editor does it get marked as an error.

Indeed, the variable field will be improved to show errors for undeclared variables while you edit the field.

Why are you doing this? Is there a feature that you are going to implement that requires us to not have the ability to use undeclared child variables?

When you previously removed the ability to use undeclared parent/top level variables, you told us to use structures if we wanted to have undeclared variables. But now it seems like you are doing another sweeping change without even warning the community in advance. Again.

Please communicate with us before doing major changes to the engine’s function…

Hey fella, I don’t remember seeing you in the front-line infantry during the Vars Wars… :military_helmet:

Anyway, I was right there at the front, sounding the charge, when someone grabbed me from behind and dragged me away from the “friendly” fire, saving my life in the process.

Then he told me something I’ll repeat to you now:

‘If they have to do it… they do it.’

I don’t recall saying any of this. Please do not make it sound like a quote unless you have an exact quote.

Declaring variables allows to:

  • get auto-completion for variable names
  • avoid to select the variable type at every usage
  • avoid mistakes in the variable name
  • allow to rename a variable and have it automatically changed in all the events

Do you have any issue declaring variables?

I didn’t mean it seriously… and it wasn’t about you. but It actually did happen to me for real in some of that threads but it wasn’t you or any of the dev. I’m sorry if you got the wrong idea.

Sorry, I misunderstood. It’s fine.

Nah, don’t worry, I could never get mad at you.
You could literally crumple me up like a piece of paper and I wouldn’t even react. :ok_hand:

That being said, I’ll admit the new update caught me a little off guard at first… it took me a while to get the hang of it.But this time, at least for me, it didn’t really hit me (as far as the project is concerned) hehe,.. so i stayed on the sidelines.

Davy I think you may be talking about something different from the OP.

There will always need to be a way to use undeclared dynamic variables for logic, which is supported by arrays and structure variables. The OP is saying that the editor is now treating this as an error if using dot notation (structure.mydynamicchild) whereas it didn’t before.

They aren’t saying that undeclared variables should be allowed in general, just that the method that is allowed today shouldn’t show up as an error.

There has been no change for dynamic access. You can still do MyStructure[MyIndexVariable]. Only variables like MyStructure.MyChildStructure.MyNumberChild becomes red when they are not declared.

The biggest issue is that it retroactively breaks projects that previously worked with the point accessor and undeclared variables.

Adding a compatibility-breaking change in a minor update is, frankly, a poor practice.

It also doesn’t really make sense to stop people from using the point accessor to use dynamic/undeclared variables, as all the features that you mentionned as advantages of forcing declared variables already worked without actively stopping the user from doing so.

It doesn’t break projects. Unless there is a regression I don’t know about, you don’t have to do any change. You can run your project and it still works the same.