nonstandard DWIMness in LOOP with unportably-ordered clauses
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Won't Fix
|
Medium
|
Unassigned |
Bug Description
In sbcl-0.9.13, the code
(loop with stack = (make-array 2 :fill-pointer 2 :initial-element t)
for length = (length stack)
while (plusp length)
for element = (vector-pop stack)
collect element)
compiles without error or warning and returns (T T). Unfortunately,
it is inconsistent with the ANSI definition of the LOOP macro,
because it mixes up VARIABLE-CLAUSEs with MAIN-CLAUSEs. Furthermore,
SBCL's interpretation of the intended meaning is only one possible,
unportable interpretation of the noncompliant code; in CLISP 2.33.2,
the code compiles with a warning
LOOP: FOR clauses should occur before the loop's main body
and then fails at runtime with
VECTOR-POP: #() has length zero
perhaps because CLISP has shuffled the clauses into an
ANSI-compliant order before proceeding.
Changed in sbcl: | |
importance: | Undecided → Medium |
status: | New → Confirmed |
Changed in sbcl: | |
assignee: | nobody → Roman Marynchak (roman-marynchak) |
status: | Confirmed → In Progress |
The simple (and hopefully the right) patch for this issue (as for now affects only WHILE). Note that some contribs fail to build with this patch, because they use the incorrect loop syntax which is prohibited by the patch.