Fix regression in &REST -> &MORE conversion caused by change a4393e3d.
commitb2936b759580b9f3ceb5ff3501d8e70c98e7eb13
authorDouglas Katzman <dougk@google.com>
Sat, 3 Jan 2015 06:20:51 +0000 (3 01:20 -0500)
committerDouglas Katzman <dougk@google.com>
Sat, 3 Jan 2015 06:20:51 +0000 (3 01:20 -0500)
tree18a34aa036e4ec990cbfedb7e5888beece5f16bd
parent73e8637236cc6bbbbf9d79496344af80f3ddbd6d
Fix regression in &REST -> &MORE conversion caused by change a4393e3d.

1) A REF node to &REST var with no lvar-dest made REST-VAR-MORE-CONTEXT-OK
   think that the &REST arg had to be listified. I couldn't figure out
   why this wasn't an issue prior to the aforementioned revision,
   but it seems not to have been, though maybe it was.

2) The + and - functions should have used DO-REST-ARG but didn't,
   only because I didn't get to them yet, which should not have
   been a problem, except that their code actually got worse without.

Note- The problem that DO-REST-ARG tries to deal with is that %REST-REF
has an internal check for whether the index arg exceeds the more-count
because NTH is perfectly valid for N greater than the length of its
input list, and in general the user might write (NTH huge-num rest-arg).
But DO-REST-ARG never does that. Unfortunately the equivalent expressions
  (IF REST-VAR (CAR REST-VAR))
  (IF (> (LENGTH REST-VAR) 0) (NTH 0 REST-VAR))
  (IF (> MORE-COUNT 0) (NTH 0 REST-VAR))
would all effectively become
  (IF (> MORE-COUNT 0) (IF (< 0 MORE-COUNT) (%MORE-ARG...) NIL))
which contains two consecutive tests of the same condition.
Not only is constraint propagation unable to elide one test,
the compiler was sure that the "else" case of the inner IF causes
a type error in the form (THE NUMBER (<mumble>)).
src/code/numbers.lisp
src/compiler/fndb.lisp
src/compiler/srctran.lisp