Opened 11 years ago

Closed 11 years ago

#392 closed defect (fixed)

Cannot use a symbol macro as default initarg.

Reported by: sionescu Owned by: gb
Priority: normal Milestone: IA-32 port
Component: ANSI CL Compliance Version: trunk
Keywords: Cc:

Description

Compiling a file containing:

(in-package :cl-user)

(define-symbol-macro foo t)

(defclass bar ()
  ((baz :initarg :baz))
  (:default-initargs :baz foo))

I get this:

;Compiling "/tmp/use-case.lisp"...
;Compiler warnings for "/tmp/use-case.lisp" :
;   In an anonymous lambda form inside an anonymous lambda form: Undeclared free variable FOO
;Loading #P"/tmp/use-case.lx32fsl"...

If I try to create an instance of BAR, I get an error "Unbound variable: FOO"

Change History (2)

comment:1 Changed 11 years ago by gb

  • Status changed from new to assigned

This should be fixed in the trunk in r11572; DEFINE-SYMBOL-MACRO wasn't storing the symbol-macro expansion in the right place in the environment, so nothing compiled in that environment would have seen the expansion.

A workaround would have been to ensure that the symbol-macro was globally defined at compile-time, e.g.:

(eval-when (:compile-toplevel ...) ;and possibly other times.
  (define-symbol-macro foo t))

comment:2 Changed 11 years ago by rme

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.