Compiler does not give error if T clause in case construct is not last one
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Fix Released
|
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://
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.
orwell:
SBCL 1.0.55.0.debian
orwell:
Linux orwell 2.6.32-
Changed in sbcl: | |
status: | Triaged → In Progress |
Changed in sbcl: | |
status: | Fix Committed → Fix Released |
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