Re: Phix loop variables and scope

new topic     » goto parent     » topic index » view thread      » older message » newer message
_tom said...

The roundabout (aka loop) runs, but I can't use the variable 'x'

Have you made the above change to psym.e and run p -cp?

_tom said...

pre-declared two

atom x = 0 
for x=2 to 7 do 
    ^ type error (for loop control variable must be an INTEGER) 

Phix does not allow floating point for-loops - however, that error is a bit harsh. I've changed pmain.e/DoFor() line 9291 as follows:

--25/5/18: 
--      elsif symtab[CN][S_vtype]!=T_integer then 
--          Aborp("type error (for loop control variable must be an INTEGER)") 
        else 
            integer cnvtyp = symtab[CN][S_vtype] 
            if cnvtyp>T_object 
            or not and_bits(cnvtyp,T_integer) then 
                Aborp("type error (for loop control variable must be an INTEGER)") 
            end if 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu