Opened 5 years ago

Last modified 2 years ago

#1476 new task

(scrutinizer) Should global types be smashed in local contexts?

Reported by: megane Owned by:
Priority: minor Milestone: 5.4
Component: scrutinizer Version: 5.0.0
Keywords: smashing Cc:
Estimated difficulty:


Currently types for globals are not smashed. Should they be smashed in, say functions?

Similar to #1475.

(define-type type (vector (or fixnum symbol)))
(: g type)
(define g (vector (the * 1)))

;; define pure alias, so printing doesn't smash
(: p (* --> undefined))
(define p print)

(define (foo)
  (compiler-typecase g (type (p "global ok")))
  (vector-set! g 0 'foo)
  (compiler-typecase g (type (p "global not smashed")))

  (let ([l g])
    (compiler-typecase l (type (p "alias ok")))
    (compiler-typecase l (type (p "alias ok after printing")))
    (vector-set! g 0 'foo)
    (compiler-typecase g (type (p "global not smashed")))
    (compiler-typecase l
      (type 'oop)
      ((vector *) (p "alias smashed"))))

  (compiler-typecase g
    (type (p "global not smashed"))
    ((vector *) (p "global smashed"))))

;; $ csc -O3 global-smashing.scm && ./global-smashing 
;; global ok
;; global not smashed
;; alias ok
;; alias ok after printing
;; global not smashed
;; alias smashed
;; global not smashed

Change History (3)

comment:1 Changed 4 years ago by sjamaan

Milestone: 5.15.2

Getting ready for 5.1, moving tickets which won't make it in to 5.2.

comment:2 Changed 4 years ago by felix winkelmann

Milestone: 5.25.3

comment:3 Changed 2 years ago by sjamaan

Milestone: 5.35.4
Note: See TracTickets for help on using tickets.