Opened 7 years ago

Last modified 7 years ago

#944 new enhancement

(DECLAIM (TYPE ...)) should be evaluated when VAR is bound or setq'ed

Reported by: fare Owned by:
Priority: normal Milestone:
Component: Compiler Version: trunk
Keywords: ITA Cc:

Description

Ethan H. Schwartz 2011-01-20 19:06:00 EST

consider the following:

optimize-settings = ((SPEED 1) (SAFETY 3) (COMPILATION-SPEED 1) (SPACE 1)
(DEBUG 3))

QRS> (defvar *my-const* 3)
*MY-CONST*
QRS> (defun is-3-p (x)
       (= x 3))
IS-3-P
QRS> (declaim (type (satisfies is-3-p) *my-const*))
NIL
QRS> (let ((*my-const* 4))
       *my-const*)
4
QRS> (setq *my-const* 5)
5
QRS> *my-const*
5
QRS> (declaim (type (satisfies is-3-p) *my-const*))
NIL

It would be much better if these forms signaled a type error.

cf SBCL's behavior given the same input:

* (defvar *my-const* 3)

*MY-CONST*
(defun is-3-p (x)
       (= x 3))

IS-3-P
* (declaim (type (satisfies is-3-p) *my-const*))

(let ((*my-const* 4))
       *my-const*)

debugger invoked on a TYPE-ERROR in thread #<THREAD "initial thread" RUNNING
{102EAE1B71}>: The value 4 is not of type (SATISFIES IS-3-P).

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

((LAMBDA NIL))
source: (LET ((*MY-CONST* 4)) *MY-CONST*)
0] 0

* (setq *my-const* 5)

debugger invoked on a TYPE-ERROR in thread #<THREAD "initial thread" RUNNING
{102EAE1B71}>: The value 5 is not of type (SATISFIES IS-3-P).

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

((LAMBDA NIL))
source: (SETQ *MY-CONST* 5)
0] 0

* *my-const*

3

Presumably evaluating DECLAIMs on setq and let should only happen at sufficiently high values of SAFETY.

Xref: was ITA bug 93331

Change History (1)

comment:1 Changed 7 years ago by gz

  • Keywords ITA added
Note: See TracTickets for help on using tickets.