Declaration for symbol-macro is ignored

Bug #2056514 reported by Jonathan Braud
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

When file-compiling the following form, I get the same optimization note as when I leave out the declaration, as if the declaration were ignored:

    (defmethod test-1 (obj)
      (declare (optimize speed))
      (symbol-macrolet ((x (slot-value obj 'x)))
        (declare (fixnum x))
        (incf x 1)))

The note is:

; in: DEFMETHOD TEST-1 (T)
; (INCF X 1)
;
; note: unable to
; associate +/(+ -) of constants
; due to type uncertainty:
; The first argument is a NUMBER, not a RATIONAL.
;
; note: forced to do GENERIC-+ (cost 10)
; unable to do inline fixnum arithmetic (cost 1) because:
; The first argument is a T, not a FIXNUM.
; The result is a (VALUES NUMBER &OPTIONAL), not a (VALUES FIXNUM &OPTIONAL).
; unable to do inline fixnum arithmetic (cost 2) because:
; The first argument is a T, not a FIXNUM.
; The result is a (VALUES NUMBER &OPTIONAL), not a (VALUES FIXNUM &OPTIONAL).
; etc.

This doesn't happen if I macroexpand the INCF by hand, or if I use DEFUN instead of DEFMETHOD, or if I use a function other than SLOT-VALUE. In other words, none of the following definitions cause that spurious optimization note:

    (defmethod test-2 (obj)
      (declare (optimize speed))
      (symbol-macrolet ((x (slot-value obj 'x)))
        (declare (fixnum x))
        (setf x (+ 1 x))))

    (defun test-3 (obj)
      (declare (optimize speed))
      (symbol-macrolet ((x (slot-value obj 'x)))
        (declare (fixnum x))
        (incf x 1)))

    (defmethod test-4 (obj)
      (declare (optimize speed))
      (symbol-macrolet ((x (foo obj)))
        (declare (fixnum x))
        (incf x 1)))

Version: SBCL 2.4.2.92-f78315fe1

Stas Boukarev (stassats)
Changed in sbcl:
status: New → 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.