DEFTRANSFORM placement of declarations is wrong when :Policy arg is used

Bug #1066451 reported by Douglas Katzman on 2012-10-14
This bug affects 2 people
Affects Status Importance Assigned to Milestone

Bug Description

This bug concerns declarations in the transform's body code, not declarations that the transform's body generates.

* (sb-c::defknown grok (t) t (sb-c::foldable))
=> (GROK)
* (sb-c::deftransform grok ((x) * *) (declare (special ridiculous)) `(foo x))
* (sb-c::deftransform grok ((x) (vector) * :policy :fast) (declare (special ridiculous)) `(fast-foo x))

; caught WARNING:
; There is no function named DECLARE. References to DECLARE in some contexts
; (like starts of blocks) have special meaning, but here it would have to be a
; function, and that shouldn't be right.
[... rest of error text elided ...]

Expected result: Those should either both work (if it makes sense for DEFTRANSFORM to accept declarations at all), or both not work (if it doesn't).

The issue is simple - the expression (UNLESS ... ,@decls-body) is wrong. It stems from essentially the same code in CMUCL.

(defmacro deftransform (name (lambda-list &optional (arg-types '*) ...
    (let (...
          (decls-body `(,@decls ,@body)))
      (multiple-value-bind (parsed-form vars)
          (parse-deftransform lambda-list
                              (if policy
                                  `((unless (policy ,n-node ,policy)

Paul Khuong (pvk) on 2014-06-12
Changed in sbcl:
status: New → Confirmed
importance: Undecided → Medium
Douglas Katzman (dougk) on 2014-06-12
Changed in sbcl:
status: Confirmed → Fix Committed
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