Steel Bank Common Lisp

Compiler does not give error if T clause in case construct is not last one

Reported by Faheem Mitha on 2012-03-19
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Medium
Unassigned

Bug Description

I'm using sbcl 1.0.55.0-1 on Debian squeeze.

CL-USER> (defparameter x 2)
X
CL-USER> (defun foo (y) (case y (t (print "matches t")) (1 (print "matches 1")) ) )
FOO
CL-USER> (foo x)
NIL

Not putting the T clause last is incorrect syntax, and I think it would be reasonable
for the compiler to at least give a warning.

This came up in the course of discussion during this answer http://stackoverflow.com/a/9760436/350713 to a SO question.

In the comments, Rainer Joswig says both "Clozure CL shows a warning and LispWorks an error" and I checked CLISP gives a warning when running FOO. GCL gives "matches t", which looks wrong to me. I would have checked ecl as well, but it is currently broken on Debian.

                                                                                            Regards, Faheem

orwell:/home/faheem# sbcl --version
SBCL 1.0.55.0.debian
orwell:/home/faheem# uname -a
Linux orwell 2.6.32-5-vserver-686-bigmem #1 SMP Mon Jan 16 19:07:05 UTC 2012 i686 GNU/Linux

Nikodemus Siivola (nikodemus) wrote :

Thank you. This seems to be a regression from 2004. :)

Will commit fix after freeze.

In my tree:

CL-USER> (defun foo (y) (case y (t (print "matches t")) (1 (print "matches 1"))))
; in: DEFUN FOO
; (CASE Y (T (PRINT "matches t")) (1 (PRINT "matches 1")))
;
; caught ERROR:
; during macroexpansion of (CASE Y (T #) ...). Use *BREAK-ON-SIGNALS* to
; intercept:
;
; Bad CASE clause:
; (T (PRINT "matches t"))
; T allowed as the key designator only in the final otherwise-clause, not in a
; normal-clause. Use (T) instead, or move the clause the correct position.
; See also:
; The ANSI Standard, Macro CASE

Changed in sbcl:
assignee: nobody → Nikodemus Siivola (nikodemus)
importance: Undecided → Medium
status: New → Triaged
Faheem Mitha (faheem-j) wrote :

Hi Nikodemus,

Thanks, it is quite thrilling to hear back from SBCL. :-)

A question - does SBCL have a regression suite? If so, how does one run it?

Minor comment: "or move the clause the correct position." should probably read
                                 "or move the clause to the correct position"

                                                                                                                       Regards, Faheem

Nikodemus Siivola (nikodemus) wrote :

cd tests && sh run-tests.sh

...thanks for the eagle-eyes, that is indeed what it should have said!

Stas Boukarev (stassats) wrote :

Does your tree handle OTHERWISE in the same manner?

Nikodemus Siivola (nikodemus) wrote :

Yup.

Changed in sbcl:
status: Triaged → In Progress
Nikodemus Siivola (nikodemus) wrote :

commit a4c8f8ac2bbbd24cd0a886c75d8a250269b3b1e5
Author: Nikodemus Siivola <email address hidden>
Date: Wed Mar 28 16:03:50 2012 +0300

    plain T and OTHERWISE not allowed in CASE normal-clauses

      lp#959687

Changed in sbcl:
assignee: Nikodemus Siivola (nikodemus) → nobody
status: In Progress → Fix Committed
Stas Boukarev (stassats) on 2012-05-21
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers