X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=tests%2Fcompiler-1.impure-cload.lisp;h=2082d0f7b7b9bd10fe01db94fc1c2d2c53a613ec;hb=8dc064d2296902f01afd9107e89a81146e3771fe;hp=1b308f9adb141649bada6b6af90474ffb3e05d8b;hpb=c5b1723b27606ba18543dec5c12d34182dba4d1c;p=sbcl.git diff --git a/tests/compiler-1.impure-cload.lisp b/tests/compiler-1.impure-cload.lisp index 1b308f9..2082d0f 100644 --- a/tests/compiler-1.impure-cload.lisp +++ b/tests/compiler-1.impure-cload.lisp @@ -77,4 +77,27 @@ (0 "GMT" . "GDT") (-2 "MET" . "MET DST")) "*The string representations of the time zones.") +;;; The old CMU CL Python compiler assumed that it was safe to infer +;;; function types (including return types) from function definitions +;;; and then use them to optimize code later. This is of course bad +;;; when functions are redefined. The problem was fixed in +;;; sbcl-0.6.12.57. +(defun foo (x) + (if (plusp x) + 1.0 + 0)) +(defun bar (x) + (typecase (foo x) + (fixnum :fixnum) + (real :real) + (string :string) + (t :t))) +(assert (eql (bar 11) :real)) +(assert (eql (bar -11) :fixnum)) +(setf (symbol-function 'foo) #'identity) +(assert (eql (bar 11) :fixnum)) +(assert (eql (bar -11.0) :real)) +(assert (eql (bar "this is a test") :string)) +(assert (eql (bar (make-hash-table)) :t)) + (sb-ext:quit :unix-status 104) ; success