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

Bug #1066451 reported by Douglas Katzman
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Medium
Unassigned

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))
=> GROK
* (sb-c::deftransform grok ((x) (vector) * :policy :fast) (declare (special ridiculous)) `(fast-foo x))

; in: SB-C:DEFTRANSFORM GROK
; (DECLARE (SPECIAL RIDICULOUS))
;
; 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)
                                      (give-up-ir1-transform))
                                    ,@decls-body)
                                  body)

Paul Khuong (pvk)
Changed in sbcl:
status: New → Confirmed
importance: Undecided → Medium
Douglas Katzman (dougk)
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.