Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Serious FOR bug in latest dev build s1964
ivorget Wrote:
Quote:Your proposed change will think that FOR f=x TO -128 STEP 2 should be BYTE, because both -128+2=-126 and 2 will fit into BYTE. But it should be INTEGER.

But for that loop to be doing anything useful x would have to be <= -128 so in most cases it would already be INTEGER and so wouldn't it be the determining type?

If x is a not a constant expression, the compiler may not be able to determine its type, so it will have to guess the correct type based on upperbound -128 and step 2 only.

Frankly, guessing types is a bad idea. ZX BASIC provides it just to reduce effort for adapting programs originally written in Sinclair BASIC (that doesn't have types), so it makes sense to provide it. But there's no perfect solution for all cases.

Messages In This Thread

Forum Jump:

Users browsing this thread: 1 Guest(s)