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

Bug #959687 reported by Faheem Mitha on 2012-03-19
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

I'm using sbcl on Debian squeeze.

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

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 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
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"))))
; (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

...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 :


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


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