godotengine / godotengine/godot
Class does not trigger static error on for loops
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
- Reproducible: 4.5-stable, 4.6-stable, 4.7-dev
- Not Reproducible: 4.3-stable
### System information
Godot v4.7.dev (56f3e2611) - Fedora 31 (KDE Plasma) on X11 - X11 display driver, Multi-window, 2 monitors - OpenGL 3 (Compatibility) - AMD Radeon(TM) HD8800 Series (PITCAIRN, DRM 3.38.0, 5.8.18-100.fc31.x86_64, LLVM 9.0.1) - Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz (8 threads) - 31.29 GiB memory
### Issue description
Using class in for loops does not trigger errors in editor, but in runtime it's fail with:
```
There was an error calling "_iter_next" on iterator object of type ():.
```
### Steps to reproduce
```gdscript
func _ready() -> void:
for i in MyCustomClass:
print(i)
class MyCustomClass:
func do_something() -> void:
pass
```
### Minimal reproduction project (MRP)
N/A
Contributor guide
Research direction
Start with the provided GDScript reproducer and trace the editor's static analysis for the `for i in MyCustomClass` expression, then compare it with the runtime `_iter_next` failure. Done means the editor reports this invalid iteration before runtime; no specific source file or test is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100