FOREACH and "TYPE is not declared" error

Previous topic - Next topic

Dark Schneider

Sometimes using FOREACH with a TYPE generates this error, i.e. I have this code:
Code (glbasic) Select

FOREACH bonus_item IN stage.bonus_items[]
NEXT

This generates an error TYPE is not declared, but if I change it to:
Code (glbasic) Select

FOR i%=0 TO LEN(stage.bonus_items[])-1
NEXT

exactly in the same place of code, it works fine.

I think the problem is accessing other TYPEs members using FOREACH, but in GLBASIC v8 this worked fine. I mark the "others" because using within a type with something like:
Code (glbasic) Select

FOREACH bonus IN self.bonus_items[]
NEXT

works fine too.

Kitty Hello

Can you post a reproduceable, small example?

Slydog

I wonder if this is related to my problem:
http://www.glbasic.com/forum/index.php?topic=5933

Is your other TYPE defined in another file?
Or, it could just be a FOREACH bug!
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Dark Schneider

Quote from: Kitty Hello on 2011-Mar-22
Can you post a reproduceable, small example?

Sorry for delay, here is.

[attachment deleted by admin]

Kitty Hello

OK, fixed in the next version.