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

Throw warning in Script-Editor on changing array you currently loop #28711

Closed
Reneator opened this issue May 5, 2019 · 4 comments
Closed

Throw warning in Script-Editor on changing array you currently loop #28711

Reneator opened this issue May 5, 2019 · 4 comments

Comments

@Reneator
Copy link

Reneator commented May 5, 2019

Godot version:
3.1.1

OS/device including version:
Windows 10

Issue description:
When i (accidentally) remove an element from the array im currently looping over in a for loop, it just breaks the loop.

Here imo it would be better to throw a warning in the editor. Especially for new-comers, as this is something you might tend to do when you are not that experienced.
The breaking of the loop for a new-comer is just behaviour that is hardly visible and difficult to find out without Debugging.

I know its a No-No in Programming to do that, but nothing is preventing you here from doing so.

Steps to reproduce:
Make array with elements
iterate over array,
delete element from array while looping

@Anutrix
Copy link
Contributor

Anutrix commented Jul 6, 2019

I wonder if someone can implement something like ConcurrentModificationException for GDScript

@Reneator
Copy link
Author

Reneator commented Jul 6, 2019

@Anutrix Do you mean a compiler-exception or runtime-exception?

@Calinou
Copy link
Member

Calinou commented Mar 1, 2021

Duplicate of #32261 (same cause).

@Anutrix
Copy link
Contributor

Anutrix commented Mar 1, 2021

@Anutrix Do you mean a compiler-exception or runtime-exception?

Both or either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants