GLBasic forum

Main forum => Bug Reports => Topic started by: Dark Schneider on 2011-Mar-22

Title: FOREACH and "TYPE is not declared" error
Post by: Dark Schneider on 2011-Mar-22
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.
Title: Re: FOREACH and "TYPE is not declared" error
Post by: Kitty Hello on 2011-Mar-22
Can you post a reproduceable, small example?
Title: Re: FOREACH and "TYPE is not declared" error
Post by: Slydog on 2011-Mar-22
I wonder if this is related to my problem:
http://www.glbasic.com/forum/index.php?topic=5933 (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!
Title: Re: FOREACH and "TYPE is not declared" error
Post by: Dark Schneider on 2011-Mar-23
Quote from: Kitty Hello on 2011-Mar-22
Can you post a reproduceable, small example?

Sorry for delay, here is.

[attachment deleted by admin]
Title: Re: FOREACH and "TYPE is not declared" error
Post by: Kitty Hello on 2011-Mar-24
OK, fixed in the next version.