Summary
(scrutinizer) Should global types be smashed in local contexts?
Metadata
- Id: f8793f57605775c1bf10ca2cc3695166508bb469
- Trac id: 1476
- Type: task
- Reporter: megane
- Owner:
- Cc:
- Status: new
- Component: scrutinizer
- Estimated difficulty:
- Resolution:
- Priority: minor
- Milestone: someday
- Version: 5.0.0
- Changetime: 2023-11-06 23:08:34 UTC
- Created: 2018-06-15 10:31:08 UTC
- Keywords: smashing
Description
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"))))
(foo)
;; $ 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
Changes and comments
[2019-04-07 12:23:24 UTC] sjamaan changed milestone from 5.1 to 5.2
[2019-04-07 12:23:24 UTC] sjamaan wrote:
Getting ready for 5.1, moving tickets which won't make it in to 5.2.