<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }}
</style>
<body>
<div class='content'>
<h3>Raymond Toy pushed to branch master at <a href="https://gitlab.common-lisp.net/cmucl/cmucl">cmucl / cmucl</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://gitlab.common-lisp.net/cmucl/cmucl/commit/e791b596f0471f9027a95e8d5959f6324bf99ac1">e791b596</a></strong>
<div>
<span>by Raymond Toy</span>
<i>at 2015-06-13T23:21:13Z</i>
</div>
<pre class='commit-message'>Fix #5: Give better error message

Give a better error message when using T clause in case

error.lisp:
o Add new invalid-case condition to handle errors from case
  expressions.

macros.lisp:
o Use new invalid-case condition to signal the invalid usage of T in
  CASE expressions.
o Replace old message with better, more informative, message. Include
  xref to ANSI CL spec.

exports.lisp:
o Export INVALID-CASE from KERNEL package.</pre>
</li>
</ul>
<h4>3 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
src/code/error.lisp
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
src/code/exports.lisp
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
src/code/macros.lisp
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://gitlab.common-lisp.net/cmucl/cmucl/commit/e791b596f0471f9027a95e8d5959f6324bf99ac1#diff-0'>
<strong>
src/code/error.lisp
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/code/error.lisp
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/code/error.lisp
</span><span style="color: #aaaaaa">@@ -25,6 +25,7 @@
</span>     simple-file-error simple-program-error simple-parse-error
           simple-style-warning simple-undefined-function
          constant-modified
<span style="color: #000000;background-color: #ddffdd">+          invalid-case
</span>           #+stack-checking stack-overflow
           #+heap-overflow-check heap-overflow))
 
<span style="color: #aaaaaa">@@ -1115,7 +1116,20 @@
</span>                      (constant-modified-function-name c))
             (print-references (reference-condition-references c) s)))
   (:default-initargs :references (list '(:ansi-cl :section (3 2 2 3)))))
<span style="color: #000000;background-color: #ffdddd">-  
</span><span style="color: #000000;background-color: #ddffdd">+
+;; For errors in CASE and friends.
+(define-condition invalid-case (reference-condition error)
+  ((name :initarg :name
+        :reader invalid-case-name)
+   (format :initarg :format-control
+          :reader invalid-case-format)
+   (args :initarg :format-arguments
+        :reader invalid-case-format-args))
+  (:report (lambda (condition stream)
+            (format stream "~A: " (invalid-case-name condition))
+            (apply #'format stream (invalid-case-format condition) (invalid-case-format-args condition))
+            (print-references (reference-condition-references condition) stream))))
+
</span> (define-condition arithmetic-error (error)
   ((operation :reader arithmetic-error-operation :initarg :operation
              :initform nil)
</code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://gitlab.common-lisp.net/cmucl/cmucl/commit/e791b596f0471f9027a95e8d5959f6324bf99ac1#diff-1'>
<strong>
src/code/exports.lisp
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/code/exports.lisp
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/code/exports.lisp
</span><span style="color: #aaaaaa">@@ -2538,7 +2538,8 @@
</span> 
           "SIMPLE-ARRAY-COMPLEX-DOUBLE-DOUBLE-FLOAT-P"
           "OBJECT-NOT-SIMPLE-ARRAY-COMPLEX-DOUBLE-DOUBLE-FLOAT-ERROR"
-          "DD-PI"))
<span style="color: #000000;background-color: #ddffdd">+           "DD-PI"
+          "INVALID-CASE"))
</span> 
 (dolist
     (name
</code></pre>

<br>
</li>
<li id='diff-2'>
<a href='https://gitlab.common-lisp.net/cmucl/cmucl/commit/e791b596f0471f9027a95e8d5959f6324bf99ac1#diff-2'>
<strong>
src/code/macros.lisp
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/code/macros.lisp
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/code/macros.lisp
</span><span style="color: #aaaaaa">@@ -1366,7 +1366,16 @@
</span>                   (error (intl:gettext "No default clause allowed in ~S: ~S") name case)
                        (push `(t nil ,@(rest case)) clauses)))
                   ((and (eq name 'case))
-                   (error (intl:gettext "T and OTHERWISE may not be used as key designators for ~A") name))
<span style="color: #000000;background-color: #ddffdd">+                    (let ((key (first case)))
+                     (error 'kernel:invalid-case
+                            :name name
+                            :format-control (intl:gettext
+                                             "~<~A is a key designator only in the final otherwise-clause. ~
+                                              Use (~A) to use it as a normal-clause or move the clause to the ~
+                                              correct position.~:@>")
+                            :format-arguments (list (list key key))
+                            :references (list '(:ansi-cl :section (5 3))
+                                              (list :ansi-cl :macro name)))))
</span>              ((eq (first case) t)
                    ;; The key T is normal clause, because it's not
                    ;; the last clause.
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://gitlab.common-lisp.net/cmucl/cmucl/commit/e791b596f0471f9027a95e8d5959f6324bf99ac1">View it on GitLab</a>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://gitlab.common-lisp.net/cmucl/cmucl/commit/e791b596f0471f9027a95e8d5959f6324bf99ac1"}}</script>
</p>
</div>
</body>
</html>