Opened 5 weeks ago

Last modified 5 weeks ago

#1475 new defect

(scrutinizer) Types for global variables are not refined by predicates

Reported by: megane Owned by:
Priority: major Milestone: 5.1
Component: scrutinizer Version: 5.0
Keywords: Cc:
Estimated difficulty: easy


(: g1 (list-of fixnum))
(define g1 '())
;; Aliased global gets refined
(let ((a g1))
  (compiler-typecase a ((list-of fixnum) 1))
  (if (null? a)
      (compiler-typecase a (null 1))
      (compiler-typecase a ((not null) 1))))

(: g2 (list-of fixnum))
(define g2 '())
(if (null? g2)
    (compiler-typecase g2 (null 1)) ;; <- error
    (compiler-typecase g2 ((pair fixnum (list-of fixnum)) 1)))

;; $ csc -O3 globals.scm
;; Error: at toplevel:
;;   (globals.scm:13) no clause applies in `compiler-typecase' for expression of type `(list-of fixnum)':
;;     null

I don't think this is an issue of non-local mutation (e.g. from other threads). You should use mutexes or some other measures to prevent mutation while, you're working on a global.

Change History (1)

comment:1 Changed 5 weeks ago by megane

Forgot to mention that I have a patch for this, if you think this should be fixed.

Note: See TracTickets for help on using tickets.