Skip to content

foreach(.. RANGE ..) should reject negative and non-integer arguments

The RANGE signature of foreach has rich undocumented behavior which hopefully has never ever been used in production code.

  • Negative values of step are handled correctly. This should be mentioned in the doc, or (my preference) it should be forbidden, and a fatal error thrown.
  • step=0 is silently overwritten by 1. Instead, a fatal error should be thrown.
  • RANGE 5 0 is silently interpreted as RANGE 5 0 -1. Instead, an empty-range warning should be printed.
  • RANGE 5 0 1 throws an error although it is a perfectly legitimate empty range.
  • RANGE 0foo 10bar 2.8 is silently interpreted as RANGE 0 10 2. Instead, a fatal error should be thrown.
Edited by Joachim Wuttke
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information